38 changes: 19 additions & 19 deletions boost/network/protocol/http/impl/https_async_connection.hpp
Expand Up @@ -34,7 +34,7 @@ namespace boost { namespace network { namespace http { namespace impl {
typedef typename base::resolver_base::resolve_function resolve_function;

https_async_connection(
boost::shared_ptr<resolver_type> resolver,
resolver_type & resolver,
resolve_function resolve,
bool follow_redirect,
optional<string_type> const & certificate_filename = optional<string_type>()
Expand All @@ -43,7 +43,7 @@ namespace boost { namespace network { namespace http { namespace impl {
resolver_(resolver),
certificate_filename_(certificate_filename),
resolve_(resolve),
request_strand_(new boost::asio::io_service::strand(resolver->get_io_service()))
request_strand_(resolver.get_io_service())
{}


Expand All @@ -55,7 +55,7 @@ namespace boost { namespace network { namespace http { namespace impl {
boost::uint16_t port_ = port(request);
resolve_(resolver_, host(request),
port_,
request_strand_->wrap(
request_strand_.wrap(
boost::bind(
&https_async_connection<Tag,version_major,version_minor>::handle_resolved,
https_async_connection<Tag,version_major,version_minor>::shared_from_this(),
Expand All @@ -73,7 +73,7 @@ namespace boost { namespace network { namespace http { namespace impl {
port
);
context_.reset(new boost::asio::ssl::context(
resolver_->get_io_service(),
resolver_.get_io_service(),
boost::asio::ssl::context::sslv23_client
)
);
Expand All @@ -84,13 +84,13 @@ namespace boost { namespace network { namespace http { namespace impl {
context_->set_verify_mode(boost::asio::ssl::context::verify_none);
}
socket_.reset(new boost::asio::ssl::stream<boost::asio::ip::tcp::socket>(
resolver_->get_io_service(),
resolver_.get_io_service(),
*context_
)
);
socket_->lowest_layer().async_connect(
endpoint,
request_strand_->wrap(
request_strand_.wrap(
boost::bind(
&https_async_connection<Tag,version_major,version_minor>::handle_connected,
https_async_connection<Tag,version_major,version_minor>::shared_from_this(),
Expand All @@ -112,7 +112,7 @@ namespace boost { namespace network { namespace http { namespace impl {
void handle_connected(boost::uint16_t port, bool get_body, resolver_iterator_pair endpoint_range, boost::system::error_code const & ec) {
if (!ec) {
socket_->async_handshake(boost::asio::ssl::stream_base::client,
request_strand_->wrap(
request_strand_.wrap(
boost::bind(
&https_async_connection<Tag,version_major,version_minor>::handle_handshake,
https_async_connection<Tag,version_major,version_minor>::shared_from_this(),
Expand All @@ -129,13 +129,13 @@ namespace boost { namespace network { namespace http { namespace impl {
port
);
socket_.reset(new boost::asio::ssl::stream<boost::asio::ip::tcp::socket>(
resolver_->get_io_service()
resolver_.get_io_service()
, *context_
)
);
socket_->lowest_layer().async_connect(
endpoint,
request_strand_->wrap(
request_strand_.wrap(
boost::bind(
&https_async_connection<Tag,version_major,version_minor>::handle_connected,
https_async_connection<Tag,version_major,version_minor>::shared_from_this(),
Expand All @@ -160,7 +160,7 @@ namespace boost { namespace network { namespace http { namespace impl {
void handle_handshake(boost::uint16_t port, bool get_body, boost::system::error_code const & ec) {
if (!ec) {
boost::asio::async_write(*socket_, boost::asio::buffer(command_string_.data(), command_string_.size()),
request_strand_->wrap(
request_strand_.wrap(
boost::bind(
&https_async_connection<Tag,version_major,version_minor>::handle_sent_request,
https_async_connection<Tag,version_major,version_minor>::shared_from_this(),
Expand Down Expand Up @@ -193,7 +193,7 @@ namespace boost { namespace network { namespace http { namespace impl {
boost::asio::mutable_buffers_1(
this->part.c_array(),
this->part.size()),
request_strand_->wrap(
request_strand_.wrap(
boost::bind(
&https_async_connection<Tag,version_major,version_minor>::handle_received_data,
https_async_connection<Tag,version_major,version_minor>::shared_from_this(),
Expand Down Expand Up @@ -221,7 +221,7 @@ namespace boost { namespace network { namespace http { namespace impl {
parsed_ok =
this->parse_version(
*socket_,
request_strand_->wrap(
request_strand_.wrap(
boost::bind(
&https_async_connection<Tag,version_major,version_minor>::handle_received_data,
https_async_connection<Tag,version_major,version_minor>::shared_from_this(),
Expand All @@ -233,7 +233,7 @@ namespace boost { namespace network { namespace http { namespace impl {
case status:
parsed_ok =
this->parse_status(*socket_,
request_strand_->wrap(
request_strand_.wrap(
boost::bind(
&https_async_connection<Tag,version_major,version_minor>::handle_received_data,
https_async_connection<Tag,version_major,version_minor>::shared_from_this(),
Expand All @@ -245,7 +245,7 @@ namespace boost { namespace network { namespace http { namespace impl {
case status_message:
parsed_ok =
this->parse_status_message(*socket_,
request_strand_->wrap(
request_strand_.wrap(
boost::bind(
&https_async_connection<Tag,version_major,version_minor>::handle_received_data,
https_async_connection<Tag,version_major,version_minor>::shared_from_this(),
Expand All @@ -257,7 +257,7 @@ namespace boost { namespace network { namespace http { namespace impl {
case headers:
fusion::tie(parsed_ok, remainder) =
this->parse_headers(*socket_,
request_strand_->wrap(
request_strand_.wrap(
boost::bind(
&https_async_connection<Tag,version_major,version_minor>::handle_received_data,
https_async_connection<Tag,version_major,version_minor>::shared_from_this(),
Expand All @@ -272,7 +272,7 @@ namespace boost { namespace network { namespace http { namespace impl {
}
this->parse_body(
*socket_,
request_strand_->wrap(
request_strand_.wrap(
boost::bind(
&https_async_connection<Tag,version_major,version_minor>::handle_received_data,
https_async_connection<Tag,version_major,version_minor>::shared_from_this(),
Expand Down Expand Up @@ -302,7 +302,7 @@ namespace boost { namespace network { namespace http { namespace impl {
} else {
this->parse_body(
*socket_,
request_strand_->wrap(
request_strand_.wrap(
boost::bind(
&https_async_connection<Tag,version_major,version_minor>::handle_received_data,
https_async_connection<Tag,version_major,version_minor>::shared_from_this(),
Expand Down Expand Up @@ -338,12 +338,12 @@ namespace boost { namespace network { namespace http { namespace impl {
}

bool follow_redirect_;
boost::shared_ptr<resolver_type> resolver_;
resolver_type & resolver_;
optional<string_type> certificate_filename_;
resolve_function resolve_;
boost::shared_ptr<boost::asio::ssl::context> context_;
boost::shared_ptr<boost::asio::ssl::stream<boost::asio::ip::tcp::socket> > socket_;
boost::shared_ptr<boost::asio::io_service::strand> request_strand_;
boost::asio::io_service::strand request_strand_;
string_type command_string_;
string_type method;
};
Expand Down
10 changes: 4 additions & 6 deletions boost/network/protocol/http/policies/async_connection.hpp
Expand Up @@ -34,7 +34,7 @@ namespace boost { namespace network { namespace http {
connection_impl(
bool follow_redirect,
resolve_function resolve,
boost::shared_ptr<resolver_type> resolver,
resolver_type & resolver,
bool https
)
{
Expand All @@ -52,7 +52,7 @@ namespace boost { namespace network { namespace http {
};

typedef boost::shared_ptr<connection_impl> connection_ptr;
connection_ptr get_connection(boost::shared_ptr<resolver_type> resolver, basic_request<Tag> const & request_) {
connection_ptr get_connection(resolver_type & resolver, basic_request<Tag> const & request_) {
string_type protocol_ = protocol(request_);
connection_ptr connection_(
new connection_impl(
Expand All @@ -62,10 +62,8 @@ namespace boost { namespace network { namespace http {
this,
_1, _2, _3, _4
)
, resolver
, boost::iequals(protocol_, string_type("https"))
)
);
, resolver
, boost::iequals(protocol_, string_type("https"))));
return connection_;
}

Expand Down
6 changes: 3 additions & 3 deletions boost/network/protocol/http/policies/async_resolver.hpp
Expand Up @@ -23,7 +23,7 @@ namespace boost { namespace network { namespace http { namespace policies {
typedef typename string<Tag>::type string_type;
typedef boost::unordered_map<string_type, resolver_iterator_pair> endpoint_cache;
typedef boost::function<void(boost::system::error_code const &,resolver_iterator_pair)> resolve_completion_function;
typedef boost::function<void(boost::shared_ptr<resolver_type>,string_type,boost::uint16_t,resolve_completion_function)> resolve_function;
typedef boost::function<void(resolver_type&,string_type,boost::uint16_t,resolve_completion_function)> resolve_function;
protected:
bool cache_resolved_;
endpoint_cache endpoint_cache_;
Expand All @@ -37,7 +37,7 @@ namespace boost { namespace network { namespace http { namespace policies {
}

void resolve(
boost::shared_ptr<resolver_type> resolver_,
resolver_type & resolver_,
string_type const & host,
boost::uint16_t port,
resolve_completion_function once_resolved
Expand All @@ -57,7 +57,7 @@ namespace boost { namespace network { namespace http { namespace policies {
resolver_type::protocol_type::v4()
, host
, lexical_cast<string_type>(port));
resolver_->async_resolve(
resolver_.async_resolve(
q,
resolver_strand_->wrap(
boost::bind(
Expand Down
4 changes: 2 additions & 2 deletions boost/network/protocol/http/policies/pooled_connection.hpp
Expand Up @@ -24,7 +24,7 @@ namespace boost { namespace network { namespace http {

template <class Tag, unsigned version_major, unsigned version_minor>
struct pooled_connection_policy : resolver_policy<Tag>::type {
protected:
protected:

typedef typename string<Tag>::type string_type;
typedef typename resolver_policy<Tag>::type resolver_base;
Expand All @@ -48,7 +48,7 @@ namespace boost { namespace network { namespace http {
pimpl.reset();
}

private:
private:

basic_response<Tag> send_request_impl(string_type const & method, basic_request<Tag> request_, bool get_body) {
boost::uint8_t count = 0;
Expand Down
7 changes: 7 additions & 0 deletions libs/network/test/http_1_0_test.cpp
Expand Up @@ -23,6 +23,13 @@ typedef boost::mpl::list<
, http::tags::http_async_8bit_tcp_resolve
> tag_types;

BOOST_AUTO_TEST_CASE_TEMPLATE(http_client_constructor_test, T, tag_types) {
typedef http::basic_client<T, 1, 0> client;
client client1; //default constructed
boost::asio::io_service io_service;
client client2(io_service); // construct with a provided io_service
}

BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test, T, tag_types) {
typedef http::basic_client<T, 1, 0> client;
typename client::request request("http://www.boost.org/");
Expand Down