Skip to content

Commit b7d3543

Browse files
committed
Fixing infinite loop in boost http_client if request stream is closed before Content-Length is satisified.
1 parent 132c739 commit b7d3543

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Release/src/http/client/http_linux.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,14 +665,19 @@ namespace web { namespace http
665665
};
666666

667667
const auto readSize = static_cast<size_t>(std::min(static_cast<uint64_t>(client_config().chunksize()), ctx->m_known_size - ctx->m_uploaded));
668-
669668
auto readbuf = ctx->_get_readbuffer();
670669
readbuf.getn(boost::asio::buffer_cast<uint8_t *>(ctx->m_body_buf.prepare(readSize)), readSize)
671670
.then([=](pplx::task<size_t> op)
672671
{
673672
try
674673
{
675-
write_chunk(op.get());
674+
const auto actualReadSize = op.get();
675+
if(actualReadSize == 0)
676+
{
677+
ctx->report_exception(http_exception("Unexpected end of request body stream encountered before Content-Length satisfied."));
678+
return;
679+
}
680+
write_chunk(actualReadSize);
676681
}
677682
catch (...)
678683
{

0 commit comments

Comments
 (0)