Skip to content

Commit 7602c3e

Browse files
Ivan  Johannessendeanberris
authored andcommitted
Fixed sync_connection_base_impl::read_body_transfer_chunk_encoding method to account for data alreay read into the buffer
1 parent 5953b8c commit 7602c3e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

boost/network/protocol/http/impl/sync_connection_base.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,13 @@ namespace boost { namespace network { namespace http { namespace impl {
158158
} while (!stopping);
159159
} else throw std::runtime_error("Unsupported Transfer-Encoding.");
160160
} else {
161-
size_t length = lexical_cast<size_t>(boost::begin(content_length_range)->second);
162-
size_t bytes_read = 0;
161+
size_t already_read = response_buffer.size( );
162+
if ( already_read )
163+
body_stream << &response_buffer;
164+
size_t length = lexical_cast<size_t>(boost::begin(content_length_range)->second) - already_read;
165+
if ( length == 0 )
166+
return;
167+
size_t bytes_read = 0;
163168
while ((bytes_read = boost::asio::read(socket_, response_buffer, boost::asio::transfer_at_least(1), error))) {
164169
body_stream << &response_buffer;
165170
length -= bytes_read;

0 commit comments

Comments
 (0)