Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc0a29e3

Browse files
committed
Incremental Request Parser Re-do (broken)
This implementation follows the range interface prescribed by theincremental response parser. As soon as this implementation is done theconcept of the incremental parser will be lifted and formalized -- thendocumented and then pushed into 0.8.
1 parentb7bce79 commitc0a29e3

File tree

3 files changed

+111
-0
lines changed

3 files changed

+111
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_REQUEST_PARSER_HPP_20101005
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_SERVER_REQUEST_PARSER_HPP_20101005
3+
4+
// Copyright 2010 Dean Michael Berris.
5+
// Distributed under the Boost Software License, Version 1.0.
6+
// (See accompanying file LICENSE_1_0.txt or copy at
7+
// http://www.boost.org/LICENSE_1_0.txt)
8+
9+
#include<utility>
10+
#include<boost/range/iterator_range.hpp>
11+
#include<boost/logic/tribool.hpp>
12+
#include<boost/fusion/tuple.hpp>
13+
14+
namespaceboost {namespacenetwork {namespacehttp {
15+
16+
template<classTag>
17+
structrequest_parser {
18+
19+
enumstate_t {
20+
method_start
21+
, method_char
22+
, method_done
23+
, uri_char
24+
, uri_done
25+
, version_h
26+
, version_t1
27+
, version_t2
28+
, version_p
29+
, version_d1
30+
, version_dot
31+
, version_d2
32+
, version_done
33+
, header_name
34+
, header_colon
35+
, header_value
36+
, header_line_done
37+
, headers_done
38+
};
39+
40+
template<classRange>
41+
fusion::tuple<logic::tribool, Range>
42+
parse_until(state_t state, Rangeconst & range) {
43+
logic::tribool parsed_ok;
44+
typedeftypename range_iterator<Range>::type iterator;
45+
iterator start =boost::begin(range)
46+
, end =boost::end(range)
47+
, current_iterator = start;
48+
49+
while (!boost::empty(range) || state != internal_state) {
50+
switch(internal_state) {
51+
default:
52+
parsed_ok =false;
53+
returnfusion::make_tuple(
54+
parsed_ok,
55+
boost::make_iterator_range(
56+
start, current_iterator
57+
)
58+
);
59+
};
60+
}
61+
}
62+
63+
private:
64+
state_t internal_state;
65+
66+
};
67+
68+
}/* http*/
69+
70+
}/* network*/
71+
72+
}/* boost*/
73+
74+
#endif/* BOOST_NETWORK_PROTOCOL_HTTP_SERVER_REQUEST_PARSER_HPP_20101005*/

‎libs/network/test/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ if (Boost_FOUND)
1818
set(
1919
TESTS
2020
http_incremental_parser
21+
http_incremental_request_parser
2122
http_1_0_test
2223
http_1_1_test
2324
http_localhost_tests
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright 2010 Dean Michael Berris.
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// (See accompanying file LICENSE_1_0.txt or copy at
4+
// http://www.boost.org/LICENSE_1_0.txt)
5+
6+
#defineBOOST_TEST_MODULE HTTP Incremental Request Parser Test
7+
#include<boost/config/warning_disable.hpp>
8+
#include<boost/test/unit_test.hpp>
9+
#include<boost/network/protocol/http/server/request_parser.hpp>
10+
#include<boost/network/tags.hpp>
11+
#include<boost/range.hpp>
12+
#include<boost/logic/tribool.hpp>
13+
#include<string>
14+
#include<iostream>
15+
16+
/** Synopsis
17+
*
18+
* Test for the HTTP Request Incremental Parser
19+
* --------------------------------------------
20+
*
21+
* In this test we fully intend to specify how an incremental HTTP request
22+
* parser should be used. This follows the HTTP Response Incremental Parser
23+
* example, and models the Incremental Parser Concept.
24+
*
25+
*/
26+
27+
namespacetags= boost::network::tags;
28+
namespacelogic= boost::logic;
29+
namespacefusion= boost::fusion;
30+
usingnamespaceboost::network::http;
31+
32+
BOOST_AUTO_TEST_CASE(incremental_parser_constructor) {
33+
request_parser<tags::default_string> p;// default constructible
34+
}
35+
36+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp