Skip to content

Commit be8e893

Browse files
committed
Fix parsing of HTTP Headers whitespace
search for the first non space character after the colon
1 parent 6e090b3 commit be8e893

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

boost/network/protocol/http/client/connection/sync_base.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ struct sync_connection_base_impl {
8484
string_type header_line, name;
8585
while (std::getline(response_stream, header_line) && header_line != "\r") {
8686
trim_right_if(header_line, boost::is_space() || boost::is_any_of("\r"));
87-
typename string_type::size_type colon_offset;
87+
typename string_type::size_type colon_offset, value_offset;
8888
if (header_line.size() && header_line[0] == ' ') {
8989
assert(!name.empty());
9090
if (name.empty())
@@ -94,7 +94,8 @@ struct sync_connection_base_impl {
9494
} else if ((colon_offset = header_line.find_first_of(':')) !=
9595
string_type::npos) {
9696
name = header_line.substr(0, colon_offset);
97-
response_ << header(name, header_line.substr(colon_offset + 2));
97+
value_offset = header_line.find_first_not_of(' ', colon_offset + 1);
98+
response_ << header(name, header_line.substr(value_offset, header_line.size() - value_offset));
9899
}
99100
}
100101
}

0 commit comments

Comments
 (0)