Skip to content

Commit f5a7209

Browse files
author
Dean Michael Berris
committed
Moving FIXME comments, adding debugging output in tests, and an additional case for HTTP/0.9 versions.
1 parent 09c705b commit f5a7209

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ namespace boost { namespace network { namespace http {
6666

6767
template <class Range>
6868
fusion::tuple<logic::tribool,range_type> parse_until(state_t stop_state, Range & range_) {
69+
//FIXME -- find a way to make better use of the Boost.String_algorithm classifiers
6970
logic::tribool parsed_ok(logic::indeterminate);
7071
iterator_type start = boost::begin(range_),
7172
current = start,
@@ -123,7 +124,6 @@ namespace boost { namespace network { namespace http {
123124
}
124125
break;
125126
case http_version_slash:
126-
// FIXME find a better way to use is_digit
127127
if (algorithm::is_digit()(*current)) {
128128
state_ = http_version_major;
129129
++current;
@@ -140,7 +140,6 @@ namespace boost { namespace network { namespace http {
140140
}
141141
break;
142142
case http_version_dot:
143-
// FIXME find a better way to use is_digit
144143
if (algorithm::is_digit()(*current)) {
145144
state_ = http_version_minor;
146145
++current;
@@ -157,7 +156,6 @@ namespace boost { namespace network { namespace http {
157156
}
158157
break;
159158
case http_version_done:
160-
// FIXME find a better way to use is_digit
161159
if (algorithm::is_digit()(*current)) {
162160
state_ = http_status_digit;
163161
++current;
@@ -166,7 +164,6 @@ namespace boost { namespace network { namespace http {
166164
}
167165
break;
168166
case http_status_digit:
169-
// FIXME find a better way to use is_digit
170167
if (algorithm::is_digit()(*current)) {
171168
++current;
172169
} else if (*current == ' ') {
@@ -177,7 +174,6 @@ namespace boost { namespace network { namespace http {
177174
}
178175
break;
179176
case http_status_done:
180-
// FIXME find a better way to use is_alnum, is_space
181177
if (algorithm::is_alnum()(*current)) {
182178
state_ = http_status_message_char;
183179
++current;
@@ -186,7 +182,6 @@ namespace boost { namespace network { namespace http {
186182
}
187183
break;
188184
case http_status_message_char:
189-
// FIXME find a better way to use is_alnum, is_space
190185
if (algorithm::is_alnum()(*current) || algorithm::is_punct()(*current) || (*current == ' ')) {
191186
++current;
192187
} else if (*current == '\r') {

libs/network/test/http_incremental_parser.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(incremental_parser_parse_http_version) {
8585
valid_http_version);
8686
BOOST_CHECK_EQUAL(parsed_ok, true);
8787
BOOST_CHECK(!boost::empty(result_range));
88-
parsed = std::string(boost::begin(result_range), boost::end(result_range));
88+
parsed.assign(boost::begin(result_range), boost::end(result_range));
8989
std::cout << "PARSED: " << parsed << " state=" << p.state() << std::endl;
9090

9191
p.reset();
@@ -95,7 +95,17 @@ BOOST_AUTO_TEST_CASE(incremental_parser_parse_http_version) {
9595
response_parser_type::http_version_done,
9696
invalid_http_version);
9797
BOOST_CHECK_EQUAL(parsed_ok, false);
98-
parsed = std::string(boost::begin(result_range), boost::end(result_range));
98+
parsed.assign(boost::begin(result_range), boost::end(result_range));
99+
std::cout << "PARSED: " << parsed << " state=" << p.state() << std::endl;
100+
101+
p.reset();
102+
valid_http_version = "HTTP/0.9 ";
103+
parsed_ok = logic::indeterminate;
104+
fusion::tie(parsed_ok, result_range) = p.parse_until(
105+
response_parser_type::http_version_done,
106+
valid_http_version);
107+
BOOST_CHECK_EQUAL(parsed_ok, true);
108+
parsed.assign(boost::begin(result_range), boost::end(result_range));
99109
std::cout << "PARSED: " << parsed << " state=" << p.state() << std::endl;
100110
}
101111

@@ -182,6 +192,7 @@ BOOST_AUTO_TEST_CASE(incremental_parser_parse_header_lines) {
182192
valid_headers);
183193
BOOST_CHECK_EQUAL(parsed_ok, true);
184194
std::string parsed1 = std::string(boost::begin(result_range), boost::end(result_range));
195+
std::cout << "PARSED: " << parsed1 << " state=" << p.state() << std::endl;
185196
p.reset(response_parser_type::http_status_message_done);
186197
std::string::const_iterator end = valid_headers.end();
187198
valid_headers.assign(boost::end(result_range), end);
@@ -190,6 +201,7 @@ BOOST_AUTO_TEST_CASE(incremental_parser_parse_header_lines) {
190201
valid_headers);
191202
BOOST_CHECK_EQUAL(parsed_ok, true);
192203
std::string parsed2 = std::string(boost::begin(result_range), boost::end(result_range));
204+
std::cout << "PARSED: " << parsed2 << " state=" << p.state() << std::endl;
193205
valid_headers.assign(boost::end(result_range), end);
194206
p.reset(response_parser_type::http_status_message_done);
195207
fusion::tie(parsed_ok, result_range) = p.parse_until(

0 commit comments

Comments
 (0)