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

Commit1823d93

Browse files
committed
Adding the HTTP Response concept, along with required wrappers and directives to make http::basic_response<> model the new concept.
1 parent6072032 commit1823d93

File tree

8 files changed

+383
-10
lines changed

8 files changed

+383
-10
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_HPP_20100603
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_HPP_20100603
3+
4+
// Copyright 2010 (c) Dean Michael Berris
5+
// Copyright 2010 (c) Sinefunc, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include<boost/network/tags.hpp>
11+
#include<boost/cstdint.hpp>
12+
13+
namespaceboost {namespacenetwork {namespacehttp {
14+
15+
template<classTag>
16+
structbasic_response;
17+
18+
template<classTag>
19+
structstatus_directive {
20+
21+
typedeftypename string<Tag>::type string_type;
22+
23+
mutable boost::uint16_t status_;
24+
25+
status_directive(boost::uint16_t status)
26+
: status_(status) {}
27+
28+
status_directive(status_directiveconst & other)
29+
: status_(other.status_) {}
30+
31+
template<classT> basic_response<T>const &operator() (basic_response<T>const & response)const {
32+
response.status() = status_;
33+
return response;
34+
}
35+
36+
};
37+
38+
inline status_directive<tags::default_>conststatus(boost::uint16_t status_) {
39+
return status_directive<tags::default_>(status_);
40+
}
41+
42+
}// namespace http
43+
44+
}// namespace network
45+
46+
}// namespace boost
47+
48+
#endif// BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_HPP_20100603
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_MESSAGE_HPP_20100603
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_MESSAGE_HPP_20100603
3+
4+
// Copyright 2010 (c) Dean Michael Berris
5+
// Copyright 2010 (c) Sinefunc, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include<boost/network/tags.hpp>
11+
12+
namespaceboost {namespacenetwork {namespacehttp {
13+
14+
template<classTag>
15+
structbasic_response;
16+
17+
template<classTag>
18+
structstatus_message_directive {
19+
20+
typedeftypename string<Tag>::type string_type;
21+
22+
mutable string_type status_message_;
23+
24+
status_message_directive(string_typeconst & status_message)
25+
: status_message_(status_message) {}
26+
27+
status_message_directive(status_message_directiveconst & other)
28+
: status_message(other.status_message_) {}
29+
30+
template<classT> basic_response<T>const &operator() (basic_response<T>const & response)const {
31+
response.status_message() = status_message_;
32+
return response;
33+
}
34+
35+
};
36+
37+
inline status_message_directive<tags::default_>conststatus_message(string<tags::default_>::typeconst & status_message_) {
38+
return status_message_directive<tags::default_>(status_message_);
39+
}
40+
41+
}// namespace http
42+
43+
}// namespace network
44+
45+
}// namespace boost
46+
47+
#endif// BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_STATUS_MESSAGE_HPP_20100603
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_VERSION_HPP_20100603
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_VERSION_HPP_20100603
3+
4+
// Copyright 2010 (c) Dean Michael Berris
5+
// Copyright 2010 (c) Sinefunc, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include<boost/network/tags.hpp>
11+
12+
namespaceboost {namespacenetwork {namespacehttp {
13+
14+
template<classTag>
15+
structbasic_response;
16+
17+
template<classTag>
18+
structversion_directive {
19+
20+
typedeftypename string<Tag>::type string_type;
21+
22+
mutable string_type version_;
23+
24+
version_directive(string_typeconst & version)
25+
: version_(version) {}
26+
27+
version_directive(version_directiveconst & other)
28+
: version_(other.version_) {}
29+
30+
template<classT> basic_response<T>const &operator() (basic_response<T>const & response)const {
31+
response.version() = version_;
32+
return response;
33+
}
34+
35+
};
36+
37+
inline version_directive<tags::default_>constversion(string<tags::default_>::typeconst & version_) {
38+
return version_directive<tags::default_>(version_);
39+
}
40+
41+
}// namespace http
42+
43+
}// namespace network
44+
45+
}// namespace boost
46+
47+
48+
#endif// BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_VERSION_HPP_20100603
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_HPP_20100603
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_HPP_20100603
3+
4+
// Copyright 2010 (c) Dean Michael Berris
5+
// Copyright 2010 (c) Sinefunc, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include<boost/cstdint.hpp>
11+
12+
namespaceboost {namespacenetwork {namespacehttp {
13+
14+
template<classTag>
15+
structbasic_response;
16+
17+
namespaceimpl {
18+
19+
template<classTag>
20+
structstatus_wrapper {
21+
22+
basic_response<Tag>const & response_;
23+
24+
explicitstatus_wrapper(basic_response<Tag>const & response)
25+
: response_(response) {}
26+
27+
status_wrapper(status_wrapperconst & other)
28+
: response_(other.response_) {}
29+
30+
operatorboost::uint16_t () {
31+
return response_.status();
32+
}
33+
34+
};
35+
36+
}// namespace impl
37+
38+
template<classTag>
39+
inline impl::status_wrapper<Tag>status(basic_response<Tag>const & response) {
40+
return impl::status_wrapper<Tag>(response);
41+
}
42+
43+
}// namespace http
44+
45+
}// namespace network
46+
47+
}// namespace boost
48+
49+
#endif// BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_HPP_20100603
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_MESSAGE_HPP_20100603
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_MESSAGE_HPP_20100603
3+
4+
// Copyright 2010 (c) Dean Michael Berris
5+
// Copyright 2010 (c) Sinefunc, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
namespaceboost {namespacenetwork {namespacehttp {
11+
12+
template<classTag>
13+
structbasic_response;
14+
15+
namespaceimpl {
16+
17+
template<classTag>
18+
structstatus_message_wrapper {
19+
20+
typedeftypename string<Tag>::type string_type;
21+
22+
basic_response<Tag>const & response_;
23+
24+
explicitstatus_message_wrapper(basic_response<Tag>const & response)
25+
: response_(response) {}
26+
27+
status_message_wrapper(status_message_wrapperconst & other)
28+
: response_(other.response_) {}
29+
30+
operatorstring_type () {
31+
return response_.status_message();
32+
}
33+
34+
};
35+
36+
}// namespace impl
37+
38+
template<classTag>
39+
inline impl::status_message_wrapper<Tag>status_message(basic_response<Tag>const & response) {
40+
return impl::status_message_wrapper<Tag>(response);
41+
}
42+
43+
}// namespace http
44+
45+
}// namespace network
46+
47+
}// namespace boost
48+
49+
#endif// BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPER_STATUS_MESSAGE_HPP_20100603
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_VERSION_HPP_20100603
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_VERSION_HPP_20100603
3+
4+
// Copyright 2010 (c) Dean Michael Berris
5+
// Copyright 2010 (c) Sinefunc, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include<boost/network/tags.hpp>
11+
12+
namespaceboost {namespacenetwork {namespacehttp {
13+
14+
template<classTag>
15+
structbasic_response;
16+
17+
namespaceimpl {
18+
19+
template<classTag>
20+
structversion_wrapper {
21+
22+
typedeftypename string<Tag>::type string_type;
23+
24+
basic_response<Tag>const & response_;
25+
26+
explicitversion_wrapper(basic_response<Tag>const & response)
27+
: response_(response) {}
28+
29+
version_wrapper(version_wrapperconst & other)
30+
: response_(other.response_) {}
31+
32+
operatorstring_type () {
33+
return response_.version();
34+
}
35+
36+
};
37+
38+
}// namespace impl
39+
40+
template<classTag>
41+
inline impl::version_wrapper<Tag>version(basic_response<Tag>const & response) {
42+
return impl::version_wrapper<Tag>(response);
43+
}
44+
45+
}// namespace http
46+
47+
}// namespace network
48+
49+
}// namespace boost
50+
51+
#endif// BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_VERSION_HPP_20100603

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

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,23 @@
1010
#include<boost/network/protocol/http/message.hpp>
1111
#include<boost/network/message.hpp>
1212

13+
#include<boost/cstdint.hpp>
14+
#include<boost/network/protocol/http/response_concept.hpp>
15+
1316
namespaceboost {namespacenetwork {namespacehttp {
1417

1518
template<classTag>
1619
structbasic_response :publicmessage_impl<Tag> {
1720
private:
1821
typedef message_impl<Tag> base_type;
19-
typedeftypename string<Tag>::type string_type;
2022

21-
string_type version_;
22-
unsignedint status_;
23-
string_type status_message_;
23+
mutablestring_type version_;
24+
mutable boost::uint16_t status_;
25+
mutablestring_type status_message_;
2426
public:
2527

2628
typedef Tag tag;
29+
typedeftypename string<Tag>::type string_type;
2730

2831
basic_response()
2932
: base_type(), version_(), status_(0u), status_message_()
@@ -33,15 +36,15 @@ namespace boost { namespace network { namespace http {
3336
: base_type(other), version_(other.version_), status_(other.status_), status_message_(other.status_message_)
3437
{ };
3538

36-
string_type &version() {
39+
string_type &version()const{
3740
return version_;
3841
};
3942

40-
unsignedint&status() {
43+
boost::uint16_t&status()const {
4144
return status_;
4245
};
4346

44-
string_type &status_message() {
47+
string_type &status_message()const{
4548
return status_message_;
4649
};
4750

@@ -61,9 +64,11 @@ namespace boost { namespace network { namespace http {
6164
};
6265

6366
template<classTag>
64-
inlinevoidswap(basic_response<Tag> & lhs, basic_response<Tag> & rhs) {
65-
lhs.swap(rhs);
66-
}
67+
inlinevoidswap(basic_response<Tag> & lhs, basic_response<Tag> & rhs) {
68+
lhs.swap(rhs);
69+
}
70+
71+
BOOST_CONCEPT_ASSERT((Response<basic_response<tags::http_default_8bit_udp_resolve> >));
6772

6873
}// namespace http
6974

@@ -73,4 +78,30 @@ namespace boost { namespace network { namespace http {
7378

7479
#include<boost/network/protocol/http/impl/response.ipp>
7580

81+
namespaceboost {namespacenetwork {namespacehttp {
82+
83+
template<classTag,classDirective>
84+
basic_response<Tag> &operator<<(
85+
basic_response<Tag> & message,
86+
Directiveconst & directive
87+
)
88+
{
89+
directive(message);
90+
return message;
91+
}
92+
93+
}// namespace http
94+
95+
}// namespace network
96+
97+
}// namespace boost
98+
99+
#include<boost/network/protocol/http/message/directives/status_message.hpp>
100+
#include<boost/network/protocol/http/message/directives/version.hpp>
101+
#include<boost/network/protocol/http/message/directives/status.hpp>
102+
103+
#include<boost/network/protocol/http/message/wrappers/version.hpp>
104+
#include<boost/network/protocol/http/message/wrappers/status.hpp>
105+
#include<boost/network/protocol/http/message/wrappers/status_message.hpp>
106+
76107
#endif// BOOST_NETWORK_PROTOCOL_HTTP_RESPONSE_HPP

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp