Skip to content

Commit e802354

Browse files
author
Dean Michael Berris
committed
Beginnings of a status parsing implementation.
1 parent 35f02eb commit e802354

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ namespace boost { namespace network { namespace http {
3434
typedef typename string<Tag>::type::const_iterator iterator_type;
3535
typedef iterator_range<iterator_type> range_type;
3636

37-
response_parser ()
38-
: state_(http_response_begin) {}
37+
explicit response_parser (state_t state=http_response_begin)
38+
: state_(state) {}
39+
3940
response_parser (response_parser const & other)
4041
: state_(other.state_) {}
42+
4143
~response_parser () {}
4244

4345
void swap(response_parser & other) {

libs/network/test/http_incremental_parser.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,18 @@ BOOST_AUTO_TEST_CASE(incremental_parser_parse_http_version) {
9595
parsed = std::string(boost::begin(result_range), boost::end(result_range));
9696
std::cout << "PARSED: " << parsed << " state=" << p.state() << std::endl;
9797
}
98+
99+
/** In this test we then want to check that we can parse a status
100+
* string right after the version string. We should expect that
101+
* the parser doesn't do any conversions from string to integer
102+
* and outsource that part to the user of the parser.
103+
*/
104+
BOOST_AUTO_TEST_CASE(incremental_parser_parse_status) {
105+
typedef response_parser<tags::default_string> response_parser_type;
106+
// We want to create a parser that has been initialized to a specific
107+
// state. In this case we assume that the parser has already parsed
108+
// the version part of the HTTP Response.
109+
response_parser_type p(response_parser_type::http_version_done);
110+
111+
}
112+

0 commit comments

Comments
 (0)