Merge pull request #444 from samarai-jk/master

ClientConnectionPool: close pool-connection if server has closed it
This commit is contained in:
Leonid Stryzhevskyi 2021-07-20 08:35:20 +03:00 committed by GitHub
commit 6c504bfb47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);