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

Commit76afcf4

Browse files
committed
Moving Server-Specific Parsers to Static Lib
In line with the changes introduced to move the Boost.Spirit requiringcode out to static libraries, the parsers used by the HTTP serverimplementation particularly the parsing of headers and the version havebeen moved out into a static library.This requires that all servers be linked against the static lib goingforward.
1 parent72d6d02 commit76afcf4

File tree

15 files changed

+173
-84
lines changed

15 files changed

+173
-84
lines changed

‎boost/network/protocol/http/impl/request.hpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ namespace boost { namespace network {
2929
/** Specialize the traits for the http_server tag.*/
3030
template<>
3131
structheaders_container<http::tags::http_server> :
32-
vector<http::tags::http_server>::apply<http::request_header<http::tags::http_server>>
32+
vector<http::tags::http_server>::apply<typenamehttp::request_header<http::tags::http_server>::type>
3333
{};
3434

3535
template<>
3636
structheaders_container<http::tags::http_async_server> :
37-
vector<http::tags::http_async_server>::apply<http::request_header<http::tags::http_async_server>>
37+
vector<http::tags::http_async_server>::apply<typenamehttp::request_header<http::tags::http_async_server>::type>
3838
{};
3939

4040
namespacehttp {
@@ -136,7 +136,7 @@ namespace http {
136136
structnot_quite_pod_request_base {
137137
typedef Tag tag;
138138
typedeftypename string<Tag>::type string_type;
139-
typedef request_header<Tag> header_type;
139+
typedeftypenamerequest_header<Tag>::type header_type;
140140
typedeftypename vector<Tag>::
141141
templateapply<header_type>::type
142142
vector_type;

‎boost/network/protocol/http/impl/request_parser.ipp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ boost::tribool basic_request_parser<Tag>::consume(basic_request<Tag> & req, char
207207
}
208208
else
209209
{
210-
req.headers.push_back(request_header<Tag>());
210+
req.headers.push_back(typenamerequest_header<Tag>::type());
211211
req.headers.back().name.push_back(input);
212212
state_ = header_name;
213213
return boost::indeterminate;

‎boost/network/protocol/http/impl/response.ipp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace boost { namespace network { namespace http {
5151
} status;
5252

5353
/// The headers to be included in the reply.
54-
typedef vector<tags::http_server>::apply<request_header<tags::http_server>>::type headers_vector;
54+
typedef vector<tags::http_server>::apply<typenamerequest_header<tags::http_server>::type>::type headers_vector;
5555
headers_vector headers;
5656

5757
/// The content to be sent in the reply.
@@ -69,7 +69,7 @@ namespace boost { namespace network { namespace http {
6969
std::vector<const_buffer> buffers;
7070
buffers.push_back(to_buffer(status));
7171
for (std::size_t i =0; i < headers.size(); ++i) {
72-
request_header<tags::http_server> & h = headers[i];
72+
typenamerequest_header<tags::http_server>::type & h = headers[i];
7373
buffers.push_back(buffer(h.name));
7474
buffers.push_back(buffer(name_value_separator));
7575
buffers.push_back(buffer(h.value));

‎boost/network/protocol/http/message/header.hpp‎

Lines changed: 76 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,57 +14,110 @@
1414
#defineBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_HPP_20101122
1515

1616
#include<boost/network/traits/string.hpp>
17-
#include<boost/fusion/adapted/struct/adapt_struct.hpp>
1817
#include<boost/fusion/include/adapt_struct.hpp>
1918
#include<boost/assign/list_of.hpp>
19+
#include<boost/network/support/is_default_wstring.hpp>
20+
#include<boost/network/support/is_default_wstring.hpp>
2021

2122
namespaceboost {namespacenetwork {namespacehttp {
2223

2324
template<classTag>
24-
structrequest_header
25-
{
26-
typedef Tag tag;
27-
typedeftypename string<Tag>::type string_type;
28-
string_type name, value;
25+
structunsupported_tag;
26+
27+
structrequest_header_narrow {
28+
typedef std::string string_type;
29+
std::string name, value;
30+
};
31+
32+
structrequest_header_wide {
33+
typedef std::wstring string_type;
34+
std::wstring name, value;
2935
};
3036

3137
template<classTag>
32-
inlinevoidswap(request_header<Tag> & l, request_header<Tag> & r) {
38+
structrequest_header
39+
: mpl::if_<
40+
is_default_string<Tag>,
41+
request_header_narrow,
42+
typename mpl::if_<
43+
is_default_wstring<Tag>,
44+
request_header_wide,
45+
unsupported_tag<Tag>
46+
>::type
47+
>
48+
{};
49+
50+
inlinevoidswap(request_header_narrow & l, request_header_narrow & r) {
3351
swap(l.name, r.name);
3452
swap(l.value, r.value);
3553
}
3654

37-
template<classTag>
38-
structresponse_header {
39-
typedef Tag tag;
40-
typedeftypename string<Tag>::type string_type;
41-
string_type name, value;
55+
inlinevoidswap(request_header_wide & l, request_header_wide & r) {
56+
swap(l.name, r.name);
57+
swap(l.value, r.value);
58+
}
59+
60+
structresponse_header_narrow {
61+
typedef std::string string_type;
62+
std::string name, value;
63+
};
64+
65+
structresponse_header_wide {
66+
typedef std::wstring string_type;
67+
std::wstring name, value;
4268
};
4369

4470
template<classTag>
45-
voidswap(response_header<Tag> & l, response_header<Tag> & r) {
71+
structresponse_header
72+
: mpl::if_<
73+
is_default_string<Tag>,
74+
response_header_narrow,
75+
typename mpl::if_<
76+
is_default_wstring<Tag>,
77+
response_header_wide,
78+
unsupported_tag<Tag>
79+
>::type
80+
>
81+
{};
82+
83+
inlinevoidswap(response_header_narrow & l, response_header_narrow & r) {
4684
std::swap(l.name, r.name);
4785
std::swap(l.value, r.value);
4886
}
4987

88+
inlinevoidswap(response_header_wide & l, response_header_wide & r) {
89+
std::swap(l.name, r.name);
90+
std::swap(l.value, r.value);
91+
}
92+
5093
}// namespace http
5194

5295
}// namespace network
5396

5497
}// namespace boost
5598

56-
BOOST_FUSION_ADAPT_TPL_STRUCT(
57-
(Tag),
58-
(boost::network::http::request_header)(Tag),
59-
(typename boost::network::string<Tag>::type, name)
60-
(typename boost::network::string<Tag>::type, value)
99+
BOOST_FUSION_ADAPT_STRUCT(
100+
boost::network::http::request_header_narrow,
101+
(std::string, name)
102+
(std::string, value)
103+
)
104+
105+
BOOST_FUSION_ADAPT_STRUCT(
106+
boost::network::http::request_header_wide,
107+
(std::wstring, name)
108+
(std::wstring, value)
109+
)
110+
111+
BOOST_FUSION_ADAPT_STRUCT(
112+
boost::network::http::response_header_narrow,
113+
(std::string, name)
114+
(std::string, value)
61115
)
62116

63-
BOOST_FUSION_ADAPT_TPL_STRUCT(
64-
(Tag),
65-
(boost::network::http::response_header) (Tag),
66-
(typename boost::network::string<Tag>::type, name)
67-
(typename boost::network::string<Tag>::type, value)
117+
BOOST_FUSION_ADAPT_STRUCT(
118+
boost::network::http::response_header_wide,
119+
(std::wstring, name)
120+
(std::wstring, value)
68121
)
69122

70123
#endif// BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_HPP_20101122

‎boost/network/protocol/http/message/header/name.hpp‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,38 @@
66
// (See accompanying file LICENSE_1_0.txt or copy at
77
// http://www.boost.org/LICENSE_1_0.txt)
88

9+
#include<boost/network/protocol/http/message/header.hpp>
910
#include<utility>
1011

1112
namespaceboost {namespacenetwork {namespacehttp {
1213

13-
template<classTag>
14-
structresponse_header;
15-
16-
template<classTag>
17-
structrequest_header;
18-
1914
template<classT1,classT2>
2015
T1 &
2116
name(std::pair<T1,T2>const & p) {
2217
return p.first;
2318
}
2419

25-
template<classTag>
26-
typename string<Tag>::typeconst &
27-
name(response_header<Tag>const & h) {
20+
inline std::stringconst &
21+
name(request_header_narrowconst & h) {
2822
return h.name;
2923
}
3024

31-
template<classTag>
32-
typename string<Tag>::typeconst &
33-
name(request_header<Tag>const & h) {
25+
inline std::wstringconst &
26+
name(request_header_wideconst &h) {
3427
return h.name;
3528
}
29+
3630

31+
inline std::stringconst &
32+
name(response_header_narrowconst & h) {
33+
return h.name;
34+
}
35+
36+
inline std::wstringconst &
37+
name(response_header_wideconst &h) {
38+
return h.name;
39+
}
40+
3741
}/* http*/
3842

3943
}/* network*/

‎boost/network/protocol/http/message/header/value.hpp‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,33 @@
1010

1111
namespaceboost {namespacenetwork {namespacehttp {
1212

13-
template<classTag>
14-
structresponse_header;
15-
16-
template<classTag>
17-
structrequest_header;
13+
structrequest_header_narrow;
14+
structrequest_header_wide;
15+
structresponse_header_narrow;
16+
structresponse_header_wide;
1817

1918
template<classT1,classT2>
2019
T1 &value(std::pair<T1,T2>const & p) {
2120
return p.second;
2221
}
2322

24-
template<classTag>
25-
typename string<Tag>::typeconst &
26-
value(response_header<Tag>const & h) {
23+
inline request_header_narrow::string_typeconst &
24+
value(request_header_narrowconst & h) {
25+
return h.value;
26+
}
27+
28+
inline request_header_wide::string_typeconst &
29+
value(request_header_wideconst & h) {
30+
return h.value;
31+
}
32+
33+
inline response_header_narrow::string_typeconst &
34+
value(response_header_narrowconst & h) {
2735
return h.value;
2836
}
2937

30-
template<classTag>
31-
typename string<Tag>::typeconst &
32-
value(request_header<Tag>const & h) {
38+
inline response_header_wide::string_typeconst &
39+
value(response_header_wideconst & h) {
3340
return h.value;
3441
}
3542

‎boost/network/protocol/http/message/header_concept.hpp‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ namespace boost { namespace network { namespace http {
1616
, Assignable<H>
1717
, CopyConstructible<H>
1818
{
19-
typedeftypename H::tag tag;
2019

2120
BOOST_CONCEPT_USAGE(Header) {
22-
typedeftypenamestring<tag>::type string_type;
21+
typedeftypenameH::string_type string_type;
2322
string_type name_ =name(header);
2423
string_type value_ =value(header);
2524
H h1, h2;

‎boost/network/protocol/http/server/async_connection.hpp‎

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include<boost/make_shared.hpp>
2121
#include<boost/network/protocol/http/server/request_parser.hpp>
2222
#include<boost/range/iterator_range.hpp>
23-
#include<boost/spirit/include/qi.hpp>
2423
#include<boost/optional.hpp>
2524
#include<boost/utility/typed_in_place_factory.hpp>
2625
#include<boost/thread/locks.hpp>
@@ -42,6 +41,9 @@
4241

4342
namespaceboost {namespacenetwork {namespacehttp {
4443

44+
externvoidparse_version(std::stringconst & partial_parsed, fusion::tuple<uint8_t,uint8_t> & version_pair);
45+
externvoidparse_headers(std::stringconst & input, std::vector<request_header_narrow> & container);
46+
4547
template<classTag,classHandler>
4648
structasync_connection : boost::enable_shared_from_this<async_connection<Tag,Handler> > {
4749

@@ -374,17 +376,8 @@ namespace boost { namespace network { namespace http {
374376
break;
375377
}elseif (parsed_ok ==true) {
376378
fusion::tuple<uint8_t,uint8_t> version_pair;
377-
usingnamespaceboost::spirit::qi;
378379
partial_parsed.append(boost::begin(result_range),boost::end(result_range));
379-
parse(
380-
partial_parsed.begin(), partial_parsed.end(),
381-
(
382-
lit("HTTP/")
383-
>> ushort_
384-
>>'.'
385-
>> ushort_
386-
)
387-
, version_pair);
380+
parse_version(partial_parsed, version_pair);
388381
request_.http_version_major = fusion::get<0>(version_pair);
389382
request_.http_version_minor = fusion::get<1>(version_pair);
390383
new_start =boost::end(result_range);
@@ -472,20 +465,6 @@ namespace boost { namespace network { namespace http {
472465
}
473466
}
474467

475-
voidparse_headers(string_type & input,typename request::headers_container_type & container) {
476-
usingnamespaceboost::spirit::qi;
477-
parse(
478-
input.begin(), input.end(),
479-
*(
480-
+(alnum|(punct-':'))
481-
>>lit(":")
482-
>> +(alnum|space|punct)
483-
>>lit("\r\n")
484-
)
485-
, container
486-
);
487-
}
488-
489468
voiddo_nothing() {}
490469

491470
template<classRange>

‎boost/network/protocol/http/server/async_server.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace boost { namespace network { namespace http {
1616
typedef basic_request<Tag> request;
1717
typedef basic_response<Tag> response;
1818
typedeftypename string<Tag>::type string_type;
19-
typedef boost::network::http::response_header<Tag> response_header;
19+
typedeftypenameboost::network::http::response_header<Tag>::type response_header;
2020
typedef async_connection<Tag,Handler> connection;
2121
typedef shared_ptr<connection> connection_ptr;
2222

‎boost/network/protocol/http/server/sync_connection.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ namespace boost { namespace network { namespace http {
8585
if (done) {
8686
if (request_.method[0] =='P') {
8787
// look for the content-length header
88-
typename std::vector<request_header<Tag> >::iterator it =
88+
typename std::vector<typenamerequest_header<Tag>::type >::iterator it =
8989
std::find_if(
9090
request_.headers.begin(),
9191
request_.headers.end(),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp