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

Commitb07773b

Browse files
committed
Implement 'ready(...)' Check for Async Response Objects
ThisCloses#24 -- now an ADL-found function 'ready' can be used tocheck whether a response object that is the result of an asynchronousfunction call to HTTP methods on the asynchronous client is ready.
1 parent5645bfc commitb07773b

File tree

5 files changed

+73
-1
lines changed

5 files changed

+73
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717

1818
namespaceboost {namespacenetwork {namespacehttp {
1919

20+
namespaceimpl {
21+
22+
template<classTag>
23+
structready_wrapper;
24+
25+
}/* impl*/
26+
2027
template<classTag>
2128
structasync_message {
2229

@@ -137,7 +144,7 @@ namespace boost { namespace network { namespace http {
137144
mutable std::set<string_type> removed_headers;
138145
mutable boost::shared_future<string_type> body_;
139146

140-
friendstructboost::network::detail::wrapper_base<Tag, async_message<Tag>>;
147+
friendstructboost::network::http::impl::ready_wrapper<Tag>;
141148
};
142149

143150
template<classTag>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_READY_HPP_20100618
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_READY_HPP_20100618
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/detail/wrapper_base.hpp>
10+
11+
namespaceboost {namespacenetwork {namespacehttp {
12+
13+
template<classTag>
14+
structasync_message;
15+
16+
namespaceimpl {
17+
template<classTag>
18+
structready_wrapper : boost::network::detail::wrapper_base_const<Tag, async_message<Tag> > {
19+
typedef boost::network::detail::wrapper_base_const<Tag, async_message<Tag> >
20+
wrapper_base;
21+
explicitready_wrapper(async_message<Tag>const & message)
22+
: wrapper_base(message) {}
23+
operatorbool () {
24+
return
25+
wrapper_base::_message.version_.is_ready()
26+
&& wrapper_base::_message.status_.is_ready()
27+
&& wrapper_base::_message.status_message_.is_ready()
28+
&& wrapper_base::_message.headers_.is_ready()
29+
&& wrapper_base::_message.body_.is_ready();
30+
}
31+
};
32+
}// namespace impl
33+
34+
template<classTag>
35+
inlineboolready(async_message<Tag>const & message) {
36+
return impl::ready_wrapper<Tag>(message);
37+
}
38+
39+
}/* http*/
40+
41+
}/* network*/
42+
43+
}/* boost*/
44+
45+
#endif/* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_READY_HPP_20100618*/

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include<boost/network/protocol/http/message/wrappers/status_message.hpp>
3131
#include<boost/network/protocol/http/message/wrappers/destination.hpp>
3232
#include<boost/network/protocol/http/message/wrappers/source.hpp>
33+
#include<boost/network/protocol/http/message/wrappers/ready.hpp>
3334

3435
#include<boost/network/protocol/http/message.hpp>
3536
#include<boost/network/protocol/http/message/async_message.hpp>

‎libs/network/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ if (Boost_FOUND)
2929
url_test
3030
http_url_test
3131
utils_thread_pool
32+
http_async_message_ready
3233
)
3334
foreach (test${TESTS})
3435
set_source_files_properties(${test}.cpp
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
// Copyright 2010 Dean Michael Berris.
3+
// Distributed under the Boost Software License, Version 1.0.
4+
// (See accompanying file LICENSE_1_0.txt or copy at
5+
// http://www.boost.org/LICENSE_1_0.txt)
6+
7+
#defineBOOST_TEST_MODULE HTTP Async Response Test
8+
#include<boost/test/unit_test.hpp>
9+
#include<boost/network/include/http/client.hpp>
10+
11+
namespacehttp= boost::network::http;
12+
13+
BOOST_AUTO_TEST_CASE(unready_state_response) {
14+
typedef http::basic_response<http::tags::http_async_8bit_udp_resolve> response;
15+
response r;
16+
BOOST_CHECK(!ready(r));
17+
}
18+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp