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

Commit2489449

Browse files
committed
WIP: Isolating ServerRequest Concept.
1 parenta418cf4 commit2489449

File tree

10 files changed

+205
-21
lines changed

10 files changed

+205
-21
lines changed

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
#include<boost/network/support/is_async.hpp>
2323
#include<boost/network/protocol/http/support/sync_only.hpp>
2424

25+
#include<boost/network/protocol/http/message/wrappers/method.hpp>
26+
#include<boost/network/protocol/http/message/modifiers/method.hpp>
27+
2528
#include<boost/cstdint.hpp>
2629

2730
namespaceboost {namespacenetwork {namespacehttp {
@@ -115,9 +118,12 @@ namespace boost { namespace network { namespace http {
115118
* basic_request template above to be
116119
* primarily and be solely a POD for performance
117120
* reasons.
121+
*
122+
* Reality check: This is not a POD because it contains a non-POD
123+
* member, the headers vector. :(
118124
*/
119125
template<classTag>
120-
structpod_request_base {
126+
structnot_quite_pod_request_base {
121127
typedef Tag tag;
122128
typedeftypename string<Tag>::type string_type;
123129
typedeftypename vector<tags::http_server>::
@@ -133,7 +139,7 @@ namespace boost { namespace network { namespace http {
133139
mutable vector_type headers;
134140
mutable string_type body;
135141

136-
voidswap(pod_request_base & r)const {
142+
voidswap(not_quite_pod_request_base & r)const {
137143
using std::swap;
138144
swap(method, r.method);
139145
swap(source, r.source);
@@ -146,10 +152,20 @@ namespace boost { namespace network { namespace http {
146152
};
147153

148154
template<>
149-
structbasic_request<tags::http_async_server> : pod_request_base<tags::http_async_server> {};
155+
structbasic_request<tags::http_async_server>
156+
: not_quite_pod_request_base<tags::http_async_server>
157+
{};
150158

151159
template<>
152-
structbasic_request<tags::http_server> : pod_request_base<tags::http_server> {};
160+
structbasic_request<tags::http_server>
161+
: not_quite_pod_request_base<tags::http_server>
162+
{};
163+
164+
template<classR>
165+
structServerRequest;
166+
167+
BOOST_CONCEPT_ASSERT((ServerRequest<basic_request<tags::http_async_server> >));
168+
BOOST_CONCEPT_ASSERT((ServerRequest<basic_request<tags::http_server> >));
153169

154170
template<classTag>
155171
inlinevoidswap(basic_request<Tag> & lhs, basic_request<Tag> & rhs) {

‎boost/network/protocol/http/message/modifiers/body.hpp‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ namespace boost { namespace network { namespace http {
1717
template<classTag>
1818
structbasic_response;
1919

20+
template<classTag>
21+
structbasic_request;
22+
2023
namespaceimpl {
2124

2225
template<classTag,classT>
@@ -29,6 +32,11 @@ namespace boost { namespace network { namespace http {
2932
response.body(future);
3033
}
3134

35+
template<classTag,classT>
36+
voidbody(basic_request<Tag> & request, Tconst & value, tags::serverconst &) {
37+
request.body = value;
38+
}
39+
3240
}
3341

3442
template<classTag,classT>
@@ -39,6 +47,16 @@ namespace boost { namespace network { namespace http {
3947
impl::body(response, value, is_async<Tag>());
4048
}
4149

50+
template<classR>
51+
structServerRequest;
52+
53+
template<classTag,classT>
54+
inlineBOOST_CONCEPT_REQUIRES(((ServerRequest<basic_request<Tag> >)),
55+
(void))
56+
body(basic_request<Tag> & request, Tconst & value) {
57+
impl::body(request, value,Tag());
58+
}
59+
4260
}// namespace http
4361

4462
namespaceimpl {

‎boost/network/protocol/http/message/modifiers/destination.hpp‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ namespace boost { namespace network { namespace http {
1515
template<classTag>
1616
structbasic_response;
1717

18+
template<classTag>
19+
structbasic_request;
20+
1821
namespaceimpl {
1922

2023
template<classTag,classT>
@@ -27,6 +30,11 @@ namespace boost { namespace network { namespace http {
2730
response.destination(future);
2831
}
2932

33+
template<classTag,classT>
34+
voiddestination(basic_request<Tag> & request, Tconst & value, tags::serverconst &) {
35+
request.destination = value;
36+
}
37+
3038
}
3139

3240
template<classR>
@@ -40,6 +48,17 @@ namespace boost { namespace network { namespace http {
4048
impl::destination(response, value, is_async<Tag>());
4149
}
4250

51+
template<classR>
52+
structServerRequest;
53+
54+
template<classTag,classT>
55+
inline
56+
BOOST_CONCEPT_REQUIRES(((ServerRequest<basic_request<Tag> >)),
57+
(void))
58+
destination(basic_request<Tag> & request, Tconst & value) {
59+
impl::destination(request, value,Tag());
60+
}
61+
4362
}// namespace http
4463

4564
namespaceimpl {

‎boost/network/protocol/http/message/modifiers/headers.hpp‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ namespace boost { namespace network { namespace http {
1515
template<classTag>
1616
structbasic_response;
1717

18+
template<classTag>
19+
structbasic_request;
20+
1821
namespaceimpl {
1922

2023
template<classTag,classT>
@@ -27,6 +30,11 @@ namespace boost { namespace network { namespace http {
2730
response.headers(future);
2831
}
2932

33+
template<classTag,classT>
34+
voidheaders(basic_request<Tag> & request, Tconst & value, tags::serverconst &) {
35+
request.headers = value;
36+
}
37+
3038
}
3139

3240
template<classTag,classT>
@@ -37,6 +45,13 @@ namespace boost { namespace network { namespace http {
3745
impl::headers(response, value, is_async<Tag>());
3846
}
3947

48+
template<classTag,classT>
49+
inlineBOOST_CONCEPT_REQUIRES(((ServerRequest<basic_request<Tag> >)),
50+
(void))
51+
headers(basic_request<Tag> & request, Tconst & value) {
52+
impl::headers(request, value,Tag());
53+
}
54+
4055
}// namespace http
4156

4257
}// namespace network
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_METHOD_HPP_20101118
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_METHOD_HPP_20101118
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<boost/network/traits/string.hpp>
10+
#include<boost/utility/enable_if.hpp>
11+
12+
namespaceboost {namespacenetwork {namespacehttp {
13+
14+
template<classTag>
15+
structbasic_request;
16+
17+
template<classTag>
18+
inlinetypename enable_if<is_server<Tag>,void>::type
19+
method(basic_request<Tag> & request,typename string<Tag>::typeconst & method_) {
20+
request.method = method_;
21+
}
22+
23+
}/* http*/
24+
25+
}/* network*/
26+
27+
}/* boost*/
28+
29+
#endif/* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_METHOD_HPP_20101118*/

‎boost/network/protocol/http/message/modifiers/source.hpp‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ namespace boost { namespace network { namespace http {
2929
response.source(future);
3030
}
3131

32+
template<classTag,classT>
33+
voidsource(basic_request<Tag> & request, Tconst & value, tags::serverconst &) {
34+
request.source = value;
35+
}
36+
3237
}
3338

3439
template<classR>
@@ -42,6 +47,17 @@ namespace boost { namespace network { namespace http {
4247
impl::source(response, value, is_async<Tag>());
4348
}
4449

50+
template<classR>
51+
structServerRequest;
52+
53+
template<classTag,classT>
54+
inline
55+
BOOST_CONCEPT_REQUIRES(((ServerRequest<basic_request<Tag> >)),
56+
(void))
57+
source(basic_request<Tag> & request, Tconst & value) {
58+
impl::source(request, value,Tag());
59+
}
60+
4561
}// namespace http
4662

4763
namespaceimpl {

‎boost/network/protocol/http/message/wrappers/helper.hpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
name (basic_request<Tag>const & message) { \
6666
return name##_wrapper<basic_request<Tag> >(message); \
6767
}
68+
6869
#endif/* BOOST_NETWORK_DEFINE_HTTP_WRAPPER*/
6970

7071
#endif/* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HELPER_20101013*/
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_METHOD_HPP_20101118
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_METHOD_HPP_20101118
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<boost/utility/enable_if.hpp>
10+
#include<boost/network/protocol/http/support/is_server.hpp>
11+
12+
namespaceboost {namespacenetwork {namespacehttp {
13+
14+
template<classTag>
15+
structbasic_request;
16+
17+
template<classTag>
18+
structmethod_wrapper {
19+
explicitmethod_wrapper(basic_request<Tag>const & message)
20+
: message_(message) {}
21+
22+
basic_request<Tag>const & message_;
23+
24+
typedeftypename basic_request<Tag>::string_type string_type;
25+
26+
operatorstring_type() {
27+
return message_.method;
28+
}
29+
};
30+
31+
template<classTag>
32+
inlinetypename enable_if<is_server<Tag>,typename string<Tag>::type >::type
33+
method(basic_request<Tag>const & message) {
34+
return method_wrapper<Tag>(message);
35+
}
36+
37+
}/* http*/
38+
39+
}/* network*/
40+
41+
}/* boost*/
42+
43+
#endif/* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_METHOD_HPP_20101118*/

‎boost/network/protocol/http/request_concept.hpp‎

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,62 @@
1616
namespaceboost {namespacenetwork {namespacehttp {
1717

1818
template<classR>
19-
structPodServerRequest
20-
: boost::network::Message<R>
19+
structServerRequest
2120
{
2221
typedeftypename R::string_type string_type;
22+
typedeftypename R::tag tag;
23+
typedeftypename R::headers_container_type headers_container_type;
24+
25+
BOOST_CONCEPT_USAGE(ServerRequest) {
26+
string_type source_, method_, destination_;
27+
boost::uint8_t major_version_, minor_version_;
28+
headers_container_type headers_;
29+
string_type body_;
30+
31+
source_ =source(request);
32+
method_ =method(request);
33+
destination_ =destination(request);
34+
major_version_ =major_version(request);
35+
minor_version_ =minor_version(request);
36+
headers_ =headers(request);
37+
body_ =body(request);
38+
39+
source(request, source_);
40+
method(request, method_);
41+
destination(request, destination_);
42+
major_version(request, major_version_);
43+
minor_version(request, minor_version_);
44+
headers(request, headers_);
45+
body(request, body_);
46+
47+
string_type name, value;
48+
49+
request << ::boost::network::source(source_)
50+
<< ::boost::network::destination(destination_)
51+
<< ::boost::network::http::method(method_)
52+
<< ::boost::network::http::major_version(major_version_)
53+
<< ::boost::network::http::minor_version(minor_version_)
54+
<< ::boost::network::header(name, value)
55+
<< ::boost::network::remove_header(name)
56+
<< ::boost::network::http::body(body_);
57+
58+
(void)source_;(void)method_;(void)destination_;
59+
(void)major_version_;(void)minor_version_;(void)headers_;
60+
(void)body_;(void)name;(void)value;
61+
}
2362

2463
private:
2564
R request;
2665
};
2766

2867
template<classR>
29-
structNormalClientRequest
68+
structClientRequest
3069
: boost::network::Message<R>
3170
{
3271
typedeftypename R::string_type string_type;
3372
typedeftypename R::port_type port_type;
3473

35-
BOOST_CONCEPT_USAGE(NormalClientRequest) {
74+
BOOST_CONCEPT_USAGE(ClientRequest) {
3675
string_type tmp;
3776
Rrequest_(tmp);
3877
swap(request, request_);// swappable via ADL
@@ -60,18 +99,6 @@ namespace boost { namespace network { namespace http {
6099
R request;
61100
};
62101

63-
template<classR>
64-
structRequest :
65-
mpl::if_<
66-
is_base_of<
67-
tags::pod,
68-
typename R::tag
69-
>,
70-
boost::network::Message<R>,
71-
NormalClientRequest<R>
72-
>::type
73-
{};
74-
75102
}// namespace http
76103

77104
}// namespace network

‎boost/network/protocol/http/traits.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
// Convenience header for including different traits implementations.
1414
#include<boost/network/protocol/http/traits/message_traits.hpp>
15-
#include<boost/network/protocol/http/traits/parser_traits.hpp>
15+
//#include <boost/network/protocol/http/traits/parser_traits.hpp>
1616
#include<boost/network/protocol/http/traits/connection_keepalive.hpp>
1717

1818
#endif// BOOST_NETWORK_PROTOCOL_HTTP_TRAITS_HPP

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp