mirror of
https://github.com/oatpp/oatpp.git
synced 2025-04-12 18:50:22 +08:00
Merge branch 'master' into v1.3.0
This commit is contained in:
commit
a5d8172006
@ -21,6 +21,7 @@ option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
|
||||
option(OATPP_INSTALL "Create installation target for oat++" ON)
|
||||
option(OATPP_BUILD_TESTS "Create test target for oat++" ON)
|
||||
option(OATPP_LINK_ATOMIC "Link atomic library for other platform than MSVC|MINGW|APPLE|FreeBSD" ON)
|
||||
option(OATPP_MSVC_LINK_STATIC_RUNTIME "MSVC: Link with static runtime (/MT and /MTd)." OFF)
|
||||
|
||||
###################################################################################################
|
||||
## COMPILATION CONFIG #############################################################################
|
||||
@ -113,6 +114,9 @@ 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")
|
||||
|
||||
include(cmake/msvc-runtime.cmake)
|
||||
configure_msvc_runtime()
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
if(OATPP_BUILD_TESTS)
|
||||
|
36
cmake/msvc-runtime.cmake
Normal file
36
cmake/msvc-runtime.cmake
Normal file
@ -0,0 +1,36 @@
|
||||
macro(configure_msvc_runtime)
|
||||
if(MSVC)
|
||||
# Set compiler options.
|
||||
set(variables
|
||||
CMAKE_C_FLAGS
|
||||
CMAKE_C_FLAGS_DEBUG
|
||||
CMAKE_C_FLAGS_MINSIZEREL
|
||||
CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS
|
||||
CMAKE_CXX_FLAGS_DEBUG
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL
|
||||
CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
|
||||
if(OATPP_MSVC_LINK_STATIC_RUNTIME)
|
||||
message(STATUS "MSVC: using statically-linked runtime (/MT and /MTd).")
|
||||
foreach(variable ${variables})
|
||||
if(${variable} MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}")
|
||||
endif()
|
||||
endforeach()
|
||||
else()
|
||||
message(STATUS "MSVC: using dynamically-linked runtime (/MD and /MDd).")
|
||||
foreach(variable ${variables})
|
||||
if(${variable} MATCHES "/MT")
|
||||
string(REGEX REPLACE "/MT" "/MD" ${variable} "${${variable}}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
foreach(variable ${variables})
|
||||
set(${variable} "${${variable}}" CACHE STRING "MSVC_${variable}" FORCE)
|
||||
endforeach()
|
||||
endif()
|
||||
endmacro(configure_msvc_runtime)
|
@ -39,7 +39,11 @@ namespace oatpp { namespace async { namespace worker {
|
||||
|
||||
void IOEventWorker::initEventQueue() {
|
||||
|
||||
#if !defined __ANDROID_API__ || __ANDROID_API__ >= 21
|
||||
m_eventQueueHandle = ::epoll_create1(0);
|
||||
#else
|
||||
m_eventQueueHandle = ::epoll_create(0);
|
||||
#endif
|
||||
|
||||
if(m_eventQueueHandle == -1) {
|
||||
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::initEventQueue()]", "Error. Call to ::epoll_create1() failed. errno=%d", errno);
|
||||
|
@ -64,6 +64,7 @@ public:
|
||||
*/
|
||||
std::string description = "";
|
||||
std::string pattern = "";
|
||||
bool required = false;
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -141,13 +141,19 @@ HttpRequestExecutor::executeOnce(const String& method,
|
||||
throw RequestExecutionError(RequestExecutionError::ERROR_CODE_CANT_PARSE_STARTING_LINE,
|
||||
"[oatpp::web::client::HttpRequestExecutor::executeOnce()]: Failed to read response.");
|
||||
}
|
||||
|
||||
auto con_hdr = result.headers.getAsMemoryLabel<oatpp::data::share::StringKeyLabelCI>("Connection");
|
||||
if (con_hdr == "close")
|
||||
{
|
||||
invalidateConnection(connectionHandle);
|
||||
}
|
||||
|
||||
auto bodyStream = oatpp::data::stream::InputStreamBufferedProxy::createShared(connection,
|
||||
buffer,
|
||||
result.bufferPosStart,
|
||||
result.bufferPosEnd,
|
||||
result.bufferPosStart != result.bufferPosEnd);
|
||||
|
||||
|
||||
return Response::createShared(result.startingLine.statusCode,
|
||||
result.startingLine.description.toString(),
|
||||
result.headers, bodyStream, m_bodyDecoder);
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
* If body size is unknown then should return -1.
|
||||
* @return - &id:oatpp::v_io_size;.
|
||||
*/
|
||||
virtual v_buff_size getKnownSize() = 0;
|
||||
virtual v_int64 getKnownSize() = 0;
|
||||
|
||||
};
|
||||
|
||||
|
@ -69,7 +69,7 @@ p_char8 BufferBody::getKnownData() {
|
||||
return m_buffer->getData();
|
||||
}
|
||||
|
||||
v_buff_size BufferBody::getKnownSize() {
|
||||
v_int64 BufferBody::getKnownSize() {
|
||||
return m_buffer->getSize();
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
* Return known size of the body.
|
||||
* @return - `v_buff_size`.
|
||||
*/
|
||||
v_buff_size getKnownSize() override;
|
||||
v_int64 getKnownSize() override;
|
||||
|
||||
};
|
||||
|
||||
|
@ -191,7 +191,7 @@ p_char8 MultipartBody::getKnownData() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
v_buff_size MultipartBody::getKnownSize() {
|
||||
v_int64 MultipartBody::getKnownSize() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ public:
|
||||
* Always returns `-1` - as body size is unknown.
|
||||
* @return - `-1`. `v_buff_size`.
|
||||
*/
|
||||
v_buff_size getKnownSize() override;
|
||||
v_int64 getKnownSize() override;
|
||||
|
||||
};
|
||||
|
||||
|
@ -89,7 +89,7 @@ void Response::send(data::stream::OutputStream* stream,
|
||||
http::encoding::EncoderProvider* contentEncoderProvider)
|
||||
{
|
||||
|
||||
v_buff_size bodySize = -1;
|
||||
v_int64 bodySize = -1;
|
||||
|
||||
if(m_body){
|
||||
|
||||
@ -132,14 +132,20 @@ void Response::send(data::stream::OutputStream* stream,
|
||||
|
||||
if (bodySize >= 0) {
|
||||
|
||||
if (bodySize + headersWriteBuffer->getCurrentPosition() < headersWriteBuffer->getCapacity()) {
|
||||
headersWriteBuffer->writeSimple(m_body->getKnownData(), bodySize);
|
||||
if(m_body->getKnownData() == nullptr) {
|
||||
headersWriteBuffer->flushToStream(stream);
|
||||
} else {
|
||||
headersWriteBuffer->flushToStream(stream);
|
||||
stream->writeExactSizeDataSimple(m_body->getKnownData(), bodySize);
|
||||
/* Reuse headers buffer */
|
||||
/* Transfer without chunked encoder */
|
||||
data::stream::transfer(m_body, stream, 0, headersWriteBuffer->getData(), headersWriteBuffer->getCapacity());
|
||||
} else {
|
||||
if (bodySize + headersWriteBuffer->getCurrentPosition() < headersWriteBuffer->getCapacity()) {
|
||||
headersWriteBuffer->writeSimple(m_body->getKnownData(), bodySize);
|
||||
headersWriteBuffer->flushToStream(stream);
|
||||
} else {
|
||||
headersWriteBuffer->flushToStream(stream);
|
||||
stream->writeExactSizeDataSimple(m_body->getKnownData(), bodySize);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
headersWriteBuffer->flushToStream(stream);
|
||||
|
@ -44,7 +44,7 @@ p_char8 StreamingBody::getKnownData() {
|
||||
}
|
||||
|
||||
|
||||
v_buff_size StreamingBody::getKnownSize() {
|
||||
v_int64 StreamingBody::getKnownSize() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
* Return known size of the body.
|
||||
* @return - `-1`.
|
||||
*/
|
||||
v_buff_size getKnownSize() override;
|
||||
v_int64 getKnownSize() override;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user