Skip to content

Commit c511896

Browse files
committed
Merge pull request cpp-netlib#44 from deanberris/0.9-devel
0.9 devel
2 parents 1657e28 + 12822aa commit c511896

File tree

4 files changed

+786
-716
lines changed

4 files changed

+786
-716
lines changed

boost/network/protocol/http/client/async_impl.hpp

+76-74
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#define BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_ASYNC_IMPL_HPP_20100623
33

44
// Copyright Dean Michael Berris 2010.
5+
// Copyright 2011 Dean Michael Berris ([email protected]).
6+
// Copyright 2011 Google, Inc.
57
// Distributed under the Boost Software License, Version 1.0.
68
// (See accompanying file LICENSE_1_0.txt or copy at
79
// http://www.boost.org/LICENSE_1_0.txt)
@@ -13,87 +15,87 @@
1315

1416
namespace boost { namespace network { namespace http {
1517

16-
template <class Tag, unsigned version_major, unsigned version_minor>
17-
struct basic_client_impl;
18+
template <class Tag, unsigned version_major, unsigned version_minor>
19+
struct basic_client_impl;
1820

19-
namespace impl {
20-
template <class Tag, unsigned version_major, unsigned version_minor>
21-
struct async_client :
22-
connection_policy<Tag,version_major,version_minor>::type
23-
{
24-
typedef
25-
typename connection_policy<Tag,version_major,version_minor>::type
26-
connection_base;
27-
typedef
28-
typename resolver<Tag>::type
29-
resolver_type;
30-
typedef
31-
typename string<Tag>::type
32-
string_type;
21+
namespace impl {
22+
template <class Tag, unsigned version_major, unsigned version_minor>
23+
struct async_client :
24+
connection_policy<Tag,version_major,version_minor>::type
25+
{
26+
typedef
27+
typename connection_policy<Tag,version_major,version_minor>::type
28+
connection_base;
29+
typedef
30+
typename resolver<Tag>::type
31+
resolver_type;
32+
typedef
33+
typename string<Tag>::type
34+
string_type;
3335

34-
typedef
35-
function<void(boost::iterator_range<char const *> const &, system::error_code const &)>
36-
body_callback_function_type;
36+
typedef
37+
function<void(boost::iterator_range<char const *> const &, system::error_code const &)>
38+
body_callback_function_type;
3739

38-
async_client(bool cache_resolved, bool follow_redirect, optional<string_type> const & certificate_filename, optional<string_type> const & verify_path)
39-
: connection_base(cache_resolved, follow_redirect),
40-
service_ptr(new boost::asio::io_service),
41-
service_(*service_ptr),
42-
resolver_(service_),
43-
sentinel_(new boost::asio::io_service::work(service_)),
44-
certificate_filename_(certificate_filename),
45-
verify_path_(verify_path)
46-
{
47-
connection_base::resolver_strand_.reset(new
48-
boost::asio::io_service::strand(service_));
49-
lifetime_thread_.reset(new boost::thread(
50-
boost::bind(
51-
&boost::asio::io_service::run,
52-
&service_
53-
)));
54-
}
40+
async_client(bool cache_resolved, bool follow_redirect, optional<string_type> const & certificate_filename, optional<string_type> const & verify_path)
41+
: connection_base(cache_resolved, follow_redirect),
42+
service_ptr(new boost::asio::io_service),
43+
service_(*service_ptr),
44+
resolver_(service_),
45+
sentinel_(new boost::asio::io_service::work(service_)),
46+
certificate_filename_(certificate_filename),
47+
verify_path_(verify_path)
48+
{
49+
connection_base::resolver_strand_.reset(new
50+
boost::asio::io_service::strand(service_));
51+
lifetime_thread_.reset(new boost::thread(
52+
boost::bind(
53+
&boost::asio::io_service::run,
54+
&service_
55+
)));
56+
}
5557

56-
async_client(bool cache_resolved, bool follow_redirect, boost::asio::io_service & service, optional<string_type> const & certificate_filename, optional<string_type> const & verify_path)
57-
: connection_base(cache_resolved, follow_redirect),
58-
service_ptr(0),
59-
service_(service),
60-
resolver_(service_),
61-
sentinel_(new boost::asio::io_service::work(service_)),
62-
certificate_filename_(certificate_filename),
63-
verify_path_(verify_path)
64-
{
65-
}
58+
async_client(bool cache_resolved, bool follow_redirect, boost::asio::io_service & service, optional<string_type> const & certificate_filename, optional<string_type> const & verify_path)
59+
: connection_base(cache_resolved, follow_redirect),
60+
service_ptr(0),
61+
service_(service),
62+
resolver_(service_),
63+
sentinel_(new boost::asio::io_service::work(service_)),
64+
certificate_filename_(certificate_filename),
65+
verify_path_(verify_path)
66+
{
67+
}
6668

67-
~async_client() throw ()
68-
{
69-
sentinel_.reset();
70-
if (lifetime_thread_.get()) {
71-
lifetime_thread_->join();
72-
lifetime_thread_.reset();
73-
}
74-
delete service_ptr;
75-
}
69+
~async_client() throw ()
70+
{
71+
sentinel_.reset();
72+
if (lifetime_thread_.get()) {
73+
lifetime_thread_->join();
74+
lifetime_thread_.reset();
75+
}
76+
delete service_ptr;
77+
}
7678

77-
basic_response<Tag> const request_skeleton(
78-
basic_request<Tag> const & request_,
79-
string_type const & method,
80-
bool get_body,
81-
body_callback_function_type callback
82-
)
83-
{
84-
typename connection_base::connection_ptr connection_;
85-
connection_ = connection_base::get_connection(resolver_, request_, certificate_filename_, verify_path_);
86-
return connection_->send_request(method, request_, get_body, callback);
87-
}
79+
basic_response<Tag> const request_skeleton(
80+
basic_request<Tag> const & request_,
81+
string_type const & method,
82+
bool get_body,
83+
body_callback_function_type callback
84+
)
85+
{
86+
typename connection_base::connection_ptr connection_;
87+
connection_ = connection_base::get_connection(resolver_, request_, certificate_filename_, verify_path_);
88+
return connection_->send_request(method, request_, get_body, callback);
89+
}
8890

89-
boost::asio::io_service * service_ptr;
90-
boost::asio::io_service & service_;
91-
resolver_type resolver_;
92-
boost::shared_ptr<boost::asio::io_service::work> sentinel_;
93-
boost::shared_ptr<boost::thread> lifetime_thread_;
94-
optional<string_type> certificate_filename_, verify_path_;
95-
};
96-
} // namespace impl
91+
boost::asio::io_service * service_ptr;
92+
boost::asio::io_service & service_;
93+
resolver_type resolver_;
94+
boost::shared_ptr<boost::asio::io_service::work> sentinel_;
95+
boost::shared_ptr<boost::thread> lifetime_thread_;
96+
optional<string_type> certificate_filename_, verify_path_;
97+
};
98+
} // namespace impl
9799

98100
} // namespace http
99101

0 commit comments

Comments
 (0)