File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
boost/network/protocol/http/parser Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 11
11
#include < boost/fusion/tuple.hpp>
12
12
#include < boost/network/traits/string.hpp>
13
13
#include < boost/logic/tribool.hpp>
14
+ #include < boost/algorithm/string/classification.hpp>
14
15
#include < utility>
15
16
16
17
namespace boost { namespace network { namespace http {
@@ -28,7 +29,9 @@ namespace boost { namespace network { namespace http {
28
29
http_version_major,
29
30
http_version_dot,
30
31
http_version_minor,
31
- http_version_done
32
+ http_version_done,
33
+ http_status_digit,
34
+ http_status_done
32
35
};
33
36
34
37
typedef typename string<Tag>::type::const_iterator iterator_type;
@@ -141,6 +144,26 @@ namespace boost { namespace network { namespace http {
141
144
parsed_ok = false ;
142
145
}
143
146
break ;
147
+ case http_version_done:
148
+ // FIXME find a better way to use is_digit
149
+ if (algorithm::is_digit ()(*current)) {
150
+ state_ = http_status_digit;
151
+ ++current;
152
+ } else {
153
+ parsed_ok = false ;
154
+ }
155
+ break ;
156
+ case http_status_digit:
157
+ // FIXME find a better way to use is_digit
158
+ if (algorithm::is_digit ()(*current)) {
159
+ ++current;
160
+ } else if (*current == ' ' ) {
161
+ state_ = http_status_done;
162
+ ++current;
163
+ } else {
164
+ parsed_ok = false ;
165
+ }
166
+ break ;
144
167
default :
145
168
parsed_ok = false ;
146
169
}
Original file line number Diff line number Diff line change @@ -116,6 +116,15 @@ BOOST_AUTO_TEST_CASE(incremental_parser_parse_status) {
116
116
response_parser_type::http_status_done,
117
117
valid_status);
118
118
BOOST_CHECK_EQUAL (parsed_ok, true );
119
+ std::string parsed = std::string (boost::begin (result_range), boost::end (result_range));
120
+ std::cout << " PARSED: " << parsed << " state=" << p.state () << std::endl;
121
+
122
+ p.reset (response_parser_type::http_version_done);
123
+ std::string invalid_status = " 200x " ;
124
+ fusion::tie (parsed_ok, result_range) = p.parse_until (
125
+ response_parser_type::http_status_done,
126
+ invalid_status);
127
+ BOOST_CHECK_EQUAL (parsed_ok, false );
119
128
parsed = std::string (boost::begin (result_range), boost::end (result_range));
120
129
std::cout << " PARSED: " << parsed << " state=" << p.state () << std::endl;
121
130
}
You can’t perform that action at this time.
0 commit comments