Skip to content

Commit 35f02eb

Browse files
author
Dean Michael Berris
committed
Adding one negative test case for the HTTP version string.
1 parent 1b71524 commit 35f02eb

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

boost/network/protocol/http/parser/incremental.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ namespace boost { namespace network { namespace http {
147147
local_range = boost::make_iterator_range(current, end);
148148
}
149149
if (state_ == stop_state) parsed_ok = true;
150+
else parsed_ok = false;
150151
return fusion::make_tuple(parsed_ok,boost::make_iterator_range(start, current));
151152
}
152153

libs/network/test/http_incremental_parser.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ BOOST_AUTO_TEST_CASE(incremental_parser_constructor) {
6363
BOOST_AUTO_TEST_CASE(incremental_parser_parse_http_version) {
6464
response_parser<tags::default_string> p; // default constructible
6565
logic::tribool parsed_ok = false;
66-
typedef response_parser<tags::default_string>::range_type range_type;
66+
typedef response_parser<tags::default_string> response_parser_type;
67+
typedef response_parser_type::range_type range_type;
6768
range_type result_range;
6869

6970
std::string valid_http_version = "HTTP/1.0 ";
7071
fusion::tie(parsed_ok, result_range) = p.parse_until(
71-
response_parser<tags::default_string>::http_version_done,
72+
response_parser_type::http_version_done,
7273
valid_http_version);
7374
BOOST_CHECK_EQUAL(parsed_ok, true);
7475
BOOST_CHECK(!boost::empty(result_range));
@@ -77,10 +78,20 @@ BOOST_AUTO_TEST_CASE(incremental_parser_parse_http_version) {
7778
p.reset();
7879
valid_http_version = "HTTP/1.1 ";
7980
fusion::tie(parsed_ok, result_range) = p.parse_until(
80-
response_parser<tags::default_string>::http_version_done,
81+
response_parser_type::http_version_done,
8182
valid_http_version);
8283
BOOST_CHECK_EQUAL(parsed_ok, true);
8384
BOOST_CHECK(!boost::empty(result_range));
8485
parsed = std::string(boost::begin(result_range), boost::end(result_range));
8586
std::cout << "PARSED: " << parsed << " state=" << p.state() << std::endl;
87+
88+
p.reset();
89+
std::string invalid_http_version = "HTTP 1.0";
90+
parsed_ok = logic::indeterminate;
91+
fusion::tie(parsed_ok, result_range) = p.parse_until(
92+
response_parser_type::http_version_done,
93+
invalid_http_version);
94+
BOOST_CHECK_EQUAL(parsed_ok, false);
95+
parsed = std::string(boost::begin(result_range), boost::end(result_range));
96+
std::cout << "PARSED: " << parsed << " state=" << p.state() << std::endl;
8697
}

0 commit comments

Comments
 (0)