Skip to content
Snippets Groups Projects
Commit 7f65fdc7 authored by Seva's avatar Seva Committed by Adrien Béraud
Browse files

http: try to read full content-length after headers

parent b00dfdf5
Branches
Tags
No related merge requests found
...@@ -917,8 +917,8 @@ Request::handle_response_header(const asio::error_code& ec) ...@@ -917,8 +917,8 @@ Request::handle_response_header(const asio::error_code& ec)
// has content-length // has content-length
if (content_length_it != response_.headers.end()) if (content_length_it != response_.headers.end())
{ {
std::getline(is, response_.body);
unsigned int content_length = atoi(content_length_it->second.c_str()); unsigned int content_length = atoi(content_length_it->second.c_str());
response_.body.append(conn_->read_bytes(content_length));
// full body already in the header // full body already in the header
if (response_.body.size() + 1 == content_length) { if (response_.body.size() + 1 == content_length) {
response_.body.append("\n"); response_.body.append("\n");
...@@ -985,9 +985,9 @@ Request::handle_response_body(const asio::error_code& ec, const size_t bytes) ...@@ -985,9 +985,9 @@ Request::handle_response_body(const asio::error_code& ec, const size_t bytes)
// read the content-length body // read the content-length body
unsigned int content_length; unsigned int content_length;
if (content_length_it != response_.headers.end() and !response_.body.empty()){ if (content_length_it != response_.headers.end() and !response_.body.empty()){
response_.body.append(conn_->read_bytes(bytes));
// extract the content-length // extract the content-length
content_length = atoi(content_length_it->second.c_str()); content_length = atoi(content_length_it->second.c_str());
response_.body.append(conn_->read_bytes(bytes));
// check if fully parsed // check if fully parsed
if (response_.body.size() == content_length) if (response_.body.size() == content_length)
parse_request(response_.body); parse_request(response_.body);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment