Browse Source

Greed Testsgit add --all

q
lganzzzo 4 years ago
parent
commit
8dd39ca65d

+ 1 - 0
CMakeLists.txt

@@ -74,6 +74,7 @@ message("\n#####################################################################
 
 message("oatpp version: '${OATPP_THIS_MODULE_VERSION}'")
 
+#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
 #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
 
 add_subdirectory(src)

+ 5 - 4
src/oatpp/web/client/HttpRequestExecutor.cpp

@@ -180,10 +180,11 @@ HttpRequestExecutor::executeOnceAsync(const String& method,
     std::shared_ptr<Body> m_body;
     std::shared_ptr<const BodyDecoder> m_bodyDecoder;
     std::shared_ptr<ConnectionHandle> m_connectionHandle;
+    oatpp::data::share::MemoryLabel m_buffer;
+    ResponseHeadersReader m_headersReader;
     std::shared_ptr<oatpp::data::stream::OutputStreamBufferedProxy> m_upstream;
   private:
     std::shared_ptr<oatpp::data::stream::IOStream> m_connection;
-    oatpp::data::share::MemoryLabel m_buffer;
   public:
     
     ExecutorCoroutine(HttpRequestExecutor* _this,
@@ -200,6 +201,8 @@ HttpRequestExecutor::executeOnceAsync(const String& method,
       , m_body(body)
       , m_bodyDecoder(bodyDecoder)
       , m_connectionHandle(connectionHandle)
+      , m_buffer(base::StrBuffer::createShared(oatpp::data::buffer::IOBuffer::BUFFER_SIZE))
+      , m_headersReader(m_buffer, 4096)
     {}
     
     Action act() override {
@@ -216,15 +219,13 @@ HttpRequestExecutor::executeOnceAsync(const String& method,
       auto request = OutgoingRequest::createShared(m_method, m_path, m_headers, m_body);
       request->putHeaderIfNotExists(Header::HOST, m_this->m_connectionProvider->getProperty("host"));
       request->putHeaderIfNotExists(Header::CONNECTION, Header::Value::CONNECTION_KEEP_ALIVE);
-      m_buffer = oatpp::data::share::MemoryLabel(oatpp::base::StrBuffer::createShared(oatpp::data::buffer::IOBuffer::BUFFER_SIZE));
       m_upstream = oatpp::data::stream::OutputStreamBufferedProxy::createShared(m_connection, m_buffer);
       return OutgoingRequest::sendAsync(request, m_upstream).next(m_upstream->flushAsync()).next(yieldTo(&ExecutorCoroutine::readResponse));
 
     }
     
     Action readResponse() {
-      ResponseHeadersReader headersReader(m_buffer, 4096);
-      return headersReader.readHeadersAsync(m_connection).callbackTo(&ExecutorCoroutine::onHeadersParsed);
+      return m_headersReader.readHeadersAsync(m_connection).callbackTo(&ExecutorCoroutine::onHeadersParsed);
     }
     
     Action onHeadersParsed(const ResponseHeadersReader::Result& result) {

+ 3 - 3
src/oatpp/web/protocol/http/incoming/ResponseHeadersReader.cpp

@@ -123,9 +123,9 @@ ResponseHeadersReader::readHeadersAsync(const std::shared_ptr<oatpp::data::strea
     
     ReaderCoroutine(ResponseHeadersReader* _this,
                     const std::shared_ptr<oatpp::data::stream::IOStream>& connection)
-    : m_this(_this)
-    , m_connection(connection)
-    , m_progress(0)
+      : m_this(_this)
+      , m_connection(connection)
+      , m_progress(0)
     {}
     
     Action act() override {

+ 2 - 2
test/oatpp/AllTestsMain.cpp

@@ -63,7 +63,7 @@ void runTests() {
 
   OATPP_LOGD("aaa", "coroutine size=%d", sizeof(oatpp::async::AbstractCoroutine));
   OATPP_LOGD("aaa", "action size=%d", sizeof(oatpp::async::Action));
-/*
+
   OATPP_RUN_TEST(oatpp::test::base::RegRuleTest);
   OATPP_RUN_TEST(oatpp::test::base::CommandLineArgumentsTest);
 
@@ -127,7 +127,7 @@ void runTests() {
     test_port.run();
 
   }
-*/
+
   {
 
     oatpp::test::web::FullTest test_virtual(0, 1000);