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

Commit1ac4b50

Browse files
committed
Fixing server request concept, adding appropriate implementations.
1 parent2489449 commit1ac4b50

File tree

18 files changed

+344
-87
lines changed

18 files changed

+344
-87
lines changed

‎boost/network/message/modifiers/clear_headers.hpp‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,26 @@
77
// http://www.boost.org/LICENSE_1_0.txt)
88

99
#include<boost/network/support/is_async.hpp>
10+
#include<boost/network/support/is_pod.hpp>
1011
#include<boost/thread/future.hpp>
12+
#include<boost/utility/enable_if.hpp>
13+
#include<boost/mpl/not.hpp>
1114

1215
namespaceboost {namespacenetwork {
1316

1417
namespaceimpl {
1518
template<classMessage,classTag>
16-
inlinevoidclear_headers(Messageconst & message, Tagconst &, mpl::false_const &) {
19+
inlinetypename enable_if<mpl::not_<is_pod<Tag> >,void>::type
20+
clear_headers(Messageconst & message, Tagconst &, mpl::false_const &) {
1721
(typenameMessage::headers_container_type()).swap(message.headers());
1822
}
1923

24+
template<classMessage,classTag>
25+
inlinetypename enable_if<is_pod<Tag>,void>::type
26+
clear_headers(Messageconst & message, Tagconst &, mpl::false_const &) {
27+
(typenameMessage::headers_container_type()).swap(message.headers);
28+
}
29+
2030
template<classMessage,classTag>
2131
inlinevoidclear_headers(Messageconst & message, Tagconst &, mpl::true_const &) {
2232
boost::promise<typename Message::headers_container_type> header_promise;

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
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-
2825
#include<boost/cstdint.hpp>
2926

3027
namespaceboost {namespacenetwork {namespacehttp {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include<boost/network/protocol/http/traits.hpp>
1616
#include<boost/network/protocol/http/message/modifiers/add_header.hpp>
1717
#include<boost/network/protocol/http/message/modifiers/remove_header.hpp>
18-
#include<boost/network/protocol/http/message/modifiers/clear_headers.hpp>
1918
#include<boost/network/message.hpp>
2019
#include<boost/network/tags.hpp>
2120
#include<string>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MAJOR_VERSION_HPP_20101120
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MAJOR_VERSION_HPP_20101120
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/protocol/http/support/is_server.hpp>
10+
#include<boost/utility/enable_if.hpp>
11+
#include<boost/cstdint.hpp>
12+
13+
namespaceboost {namespacenetwork {namespacehttp {
14+
15+
template<classTag>
16+
structbasic_request;
17+
18+
structmajor_version_directive {
19+
boost::uint8_t major_version;
20+
explicitmajor_version_directive(boost::uint8_t major_version)
21+
: major_version(major_version) {}
22+
template<classTag>
23+
voidoperator()(basic_request<Tag> & request)const {
24+
request.http_version_major = major_version;
25+
}
26+
};
27+
28+
inline major_version_directive
29+
major_version(boost::uint8_t major_version_) {
30+
returnmajor_version_directive(major_version_);
31+
}
32+
33+
}/* http*/
34+
35+
}/* network*/
36+
37+
}/* boost*/
38+
39+
#endif/* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MAJOR_VERSION_HPP_20101120*/
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_METHOD_HPP_20101120
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_METHOD_HPP_20101120
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+
namespaceboost {namespacenetwork {namespacehttp {
10+
11+
BOOST_NETWORK_STRING_DIRECTIVE(method, method_,
12+
message.method(method_),
13+
message.method=method_);
14+
15+
}/* http*/
16+
17+
}/* network*/
18+
19+
}/* booet*/
20+
21+
#endif/* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_METHOD_HPP_20101120*/
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MINOR_VERSION_HPP_20101120
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MINOR_VERSION_HPP_20101120
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/protocol/http/support/is_server.hpp>
10+
#include<boost/utility/enable_if.hpp>
11+
#include<boost/cstdint.hpp>
12+
13+
namespaceboost {namespacenetwork {namespacehttp {
14+
15+
template<classTag>
16+
structbasic_request;
17+
18+
structminor_version_directive {
19+
boost::uint8_t minor_version;
20+
explicitminor_version_directive(boost::uint8_t minor_version)
21+
: minor_version(minor_version) {}
22+
template<classTag>
23+
voidoperator()(basic_request<Tag> & request)const {
24+
request.http_version_minor = minor_version;
25+
}
26+
};
27+
28+
inline minor_version_directive
29+
minor_version(boost::uint8_t minor_version_) {
30+
returnminor_version_directive(minor_version_);
31+
}
32+
33+
}/* http*/
34+
35+
}/* network*/
36+
37+
}/* boost*/
38+
39+
#endif/* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_MINOR_VERSION_HPP_20101120*/
40+

‎boost/network/protocol/http/message/directives/status.hpp‎

Lines changed: 45 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -21,61 +21,57 @@ namespace boost { namespace network { namespace http {
2121
template<classTag>
2222
structbasic_response;
2323

24-
namespaceimpl {
25-
26-
structstatus_directive {
27-
28-
boost::variant<
29-
boost::uint16_t,
30-
boost::shared_future<boost::uint16_t>
31-
> status_;
32-
33-
status_directive(boost::uint16_t status)
34-
: status_(status) {}
35-
36-
status_directive(boost::shared_future<boost::uint16_t>const & status)
37-
: status_(status) {}
38-
39-
status_directive(status_directiveconst & other)
40-
: status_(other.status_) {}
41-
42-
template<classTag>
43-
structvalue
44-
: mpl::if_<
45-
is_async<Tag>,
46-
boost::shared_future<boost::uint16_t>,
47-
boost::uint16_t
48-
>
49-
{};
50-
51-
template<classTag>
52-
structstatus_visitor : boost::static_visitor<> {
53-
basic_response<Tag>const & response;
54-
status_visitor(basic_response<Tag>const & response)
55-
: response(response) {}
56-
57-
voidoperator()(typename value<Tag>::typeconst & status_)const {
58-
response.status(status_);
59-
}
60-
61-
template<classT>
62-
voidoperator()(Tconst &)const {
63-
// FIXME fail here!
64-
}
65-
};
66-
67-
template<classTag> basic_response<Tag>const &operator() (basic_response<Tag>const & response)const {
68-
apply_visitor(status_visitor<Tag>(response), status_);
69-
return response;
24+
structstatus_directive {
25+
26+
boost::variant<
27+
boost::uint16_t,
28+
boost::shared_future<boost::uint16_t>
29+
> status_;
30+
31+
explicitstatus_directive(boost::uint16_t status)
32+
: status_(status) {}
33+
34+
explicitstatus_directive(boost::shared_future<boost::uint16_t>const & status)
35+
: status_(status) {}
36+
37+
status_directive(status_directiveconst & other)
38+
: status_(other.status_) {}
39+
40+
template<classTag>
41+
structvalue
42+
: mpl::if_<
43+
is_async<Tag>,
44+
boost::shared_future<boost::uint16_t>,
45+
boost::uint16_t
46+
>
47+
{};
48+
49+
template<classTag>
50+
structstatus_visitor : boost::static_visitor<> {
51+
basic_response<Tag>const & response;
52+
status_visitor(basic_response<Tag>const & response)
53+
: response(response) {}
54+
55+
voidoperator()(typename value<Tag>::typeconst & status_)const {
56+
response.status(status_);
7057
}
7158

59+
template<classT>
60+
voidoperator()(Tconst &)const {
61+
// FIXME fail here!
62+
}
7263
};
7364

74-
}// namespace impl
65+
template<classTag> basic_response<Tag>const &operator() (basic_response<Tag>const & response)const {
66+
apply_visitor(status_visitor<Tag>(response), status_);
67+
return response;
68+
}
69+
70+
};
7571

7672
template<classT>
77-
inlineimpl::status_directiveconststatus(Tconst & status_) {
78-
returnimpl::status_directive(status_);
73+
inline status_directiveconststatus(Tconst & status_) {
74+
returnstatus_directive(status_);
7975
}
8076

8177
}// namespace http

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace boost { namespace network {
1414
namespaceimpl {
1515

1616
template<classMessage,classKeyType,classValueType,classAsync>
17-
inlinevoidadd_header(Messageconst & message, KeyTypeconst & key, ValueTypeconst & value, http::tags::http_serverconst &, Asyncconst &) {
17+
inlinevoidadd_header(Messageconst & message, KeyTypeconst & key, ValueTypeconst & value, http::tags::serverconst &, Asyncconst &) {
1818
typedeftypename Message::headers_container_type::value_type value_type;
1919
value_type header_ = { key, value };
2020
message.headers.insert(message.headers.end(), header_);

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

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_MAJOR_VERSION_HPP_20101120
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_MAJOR_VERSION_HPP_20101120
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/protocol/http/support/is_server.hpp>
10+
#include<boost/utility/enable_if.hpp>
11+
#include<boost/cstdint.hpp>
12+
13+
namespaceboost {namespacenetwork {namespacehttp {
14+
15+
template<classTag>
16+
structbasic_request;
17+
18+
template<classTag>
19+
inlinetypename enable_if<is_server<Tag>,void>::type
20+
major_version(basic_request<Tag> & request, boost::uint8_t major_version_) {
21+
request.http_version_major = major_version_;
22+
}
23+
24+
}/* http*/
25+
26+
}/* network*/
27+
28+
}/* boost*/
29+
30+
#endif/* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_MAJOR_VERSION_HPP_20101120*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp