Skip to content

Commit

Permalink
Fixed a bug that too many bytes were expected during chunked body pro…
Browse files Browse the repository at this point in the history
…cessing.
  • Loading branch information
Mike-ECT authored and glynos committed Jul 29, 2012
1 parent 6cb7388 commit c60bf39
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions boost/network/protocol/http/client/connection/sync_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,20 @@ namespace boost { namespace network { namespace http { namespace impl {
throw boost::system::system_error(error);
} else {
bool stopping_inner = false;
std::istreambuf_iterator<char> eos;
std::istreambuf_iterator<char> stream_iterator0(&response_buffer);
for (; chunk_size > 0 && stream_iterator0 != eos; --chunk_size)
body_stream << *stream_iterator0++;

do {
std::size_t chunk_bytes_read = read(socket_, response_buffer, boost::asio::transfer_at_least(chunk_size), error);
if (chunk_bytes_read == 0) {
if (error != boost::asio::error::eof) throw boost::system::system_error(error);
stopping_inner = true;
if (chunk_size != 0) {
std::size_t chunk_bytes_read = read(socket_, response_buffer, boost::asio::transfer_at_least(chunk_size), error);
if (chunk_bytes_read == 0) {
if (error != boost::asio::error::eof) throw boost::system::system_error(error);
stopping_inner = true;
}
}

std::istreambuf_iterator<char> eos;
std::istreambuf_iterator<char> stream_iterator(&response_buffer);
for (; chunk_size > 0 && stream_iterator != eos; --chunk_size)
body_stream << *stream_iterator++;
Expand Down

0 comments on commit c60bf39

Please sign in to comment.