Skip to content

Commit c9db379

Browse files
authored
Fix http 1.1 streaming on close connection (#2527)
1 parent 9784c61 commit c9db379

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

lib/src/HttpResponseImpl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ void HttpResponseImpl::makeHeaderString(trantor::MsgBuffer &buffer)
750750
{
751751
// When the headers are created, it is time to set the transfer
752752
// encoding to chunked if the contents size is not specified
753-
if (!ifCloseConnection() &&
753+
if (version_ != Version::kHttp10 &&
754754
headers_.find("content-length") == headers_.end())
755755
{
756756
LOG_DEBUG << "send stream with transfer-encoding chunked";

lib/src/HttpServer.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -985,15 +985,15 @@ void HttpServer::sendResponse(const TcpConnectionPtr &conn,
985985
auto &asyncStreamCallback = respImplPtr->asyncStreamCallback();
986986
if (asyncStreamCallback)
987987
{
988-
if (!respImplPtr->ifCloseConnection())
988+
if (respImplPtr->version() != Version::kHttp10)
989989
{
990990
asyncStreamCallback(
991991
std::make_unique<ResponseStream>(conn->sendAsyncStream(
992992
respImplPtr->asyncStreamKickoffDisabled())));
993993
}
994994
else
995995
{
996-
LOG_INFO << "Chunking Set CloseConnection !!!";
996+
LOG_INFO << "Async stream not supported for HTTP/1.0";
997997
}
998998
}
999999
auto &streamCallback = respImplPtr->streamCallback();
@@ -1069,15 +1069,15 @@ void HttpServer::sendResponses(
10691069
{
10701070
conn->send(buffer);
10711071
buffer.retrieveAll();
1072-
if (!respImplPtr->ifCloseConnection())
1072+
if (respImplPtr->version() != Version::kHttp10)
10731073
{
10741074
asyncStreamCallback(
10751075
std::make_unique<ResponseStream>(conn->sendAsyncStream(
10761076
respImplPtr->asyncStreamKickoffDisabled())));
10771077
}
10781078
else
10791079
{
1080-
LOG_INFO << "Chunking Set CloseConnection !!!";
1080+
LOG_INFO << "Async stream not supported for HTTP/1.0";
10811081
}
10821082
}
10831083
auto &streamCallback = respImplPtr->streamCallback();

0 commit comments

Comments
 (0)