diff --git a/boost/network/protocol/http/parser/incremental.hpp b/boost/network/protocol/http/parser/incremental.hpp index c64449ac3..f51cba406 100644 --- a/boost/network/protocol/http/parser/incremental.hpp +++ b/boost/network/protocol/http/parser/incremental.hpp @@ -228,6 +228,12 @@ namespace boost { namespace network { namespace http { if (*current == ':') { state_ = http_header_colon; ++current; + } else if (*current == '\r') { + state_ = http_header_line_cr; + ++current; + } else if (*current == '\n') { + state_ = http_header_line_done; + ++current; } else if (algorithm::is_alnum()(*current) || algorithm::is_space()(*current) || algorithm::is_punct()(*current)) { ++current; } else { diff --git a/libs/network/test/http/response_incremental_parser_test.cpp b/libs/network/test/http/response_incremental_parser_test.cpp index 34cf9307c..1925b4509 100644 --- a/libs/network/test/http/response_incremental_parser_test.cpp +++ b/libs/network/test/http/response_incremental_parser_test.cpp @@ -348,5 +348,30 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(incremental_parser_parse_header_lines, eol, eol_ty valid_headers); BOOST_CHECK_EQUAL(parsed_ok, true); BOOST_CHECK(parsed1 != parsed2); + + p.reset(response_parser_type::http_status_message_done); + valid_headers = "Content-Type: text/html;" + eol::literal + "charset=utf-8" + eol::literal + eol::literal; + fusion::tie(parsed_ok, result_range) = p.parse_until( + response_parser_type::http_header_line_done, + valid_headers); + BOOST_CHECK_EQUAL(parsed_ok, true); + parsed1 = std::string(boost::begin(result_range), boost::end(result_range)); + std::cout << "PARSED: " << parsed1 << " state=" << p.state() << std::endl; + p.reset(response_parser_type::http_status_message_done); + end = valid_headers.end(); + valid_headers.assign(boost::end(result_range), end); + fusion::tie(parsed_ok, result_range) = p.parse_until( + response_parser_type::http_header_line_done, + valid_headers); + BOOST_CHECK_EQUAL(parsed_ok, true); + parsed2 = std::string(boost::begin(result_range), boost::end(result_range)); + std::cout << "PARSED: " << parsed2 << " state=" << p.state() << std::endl; + valid_headers.assign(boost::end(result_range), end); + p.reset(response_parser_type::http_status_message_done); + fusion::tie(parsed_ok, result_range) = p.parse_until( + response_parser_type::http_headers_done, + valid_headers); + BOOST_CHECK_EQUAL(parsed_ok, true); + BOOST_CHECK(parsed1 != parsed2); }