Merge branch 'akonskarm-master'
This commit is contained in:
commit
7e06ac1072
|
@ -44,6 +44,15 @@ session::session(boost::asio::io_service &io_service, const std::string &host,
|
||||||
impl_->start_resolve(host, service);
|
impl_->start_resolve(host, service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
session::session(boost::asio::io_service &io_service,
|
||||||
|
const boost::asio::ip::tcp::endpoint &local_endpoint,
|
||||||
|
const std::string &host, const std::string &service)
|
||||||
|
: impl_(std::make_shared<session_tcp_impl>(
|
||||||
|
io_service, local_endpoint, host, service,
|
||||||
|
boost::posix_time::seconds(60))) {
|
||||||
|
impl_->start_resolve(host, service);
|
||||||
|
}
|
||||||
|
|
||||||
session::session(boost::asio::io_service &io_service, const std::string &host,
|
session::session(boost::asio::io_service &io_service, const std::string &host,
|
||||||
const std::string &service,
|
const std::string &service,
|
||||||
const boost::posix_time::time_duration &connect_timeout)
|
const boost::posix_time::time_duration &connect_timeout)
|
||||||
|
@ -52,6 +61,15 @@ session::session(boost::asio::io_service &io_service, const std::string &host,
|
||||||
impl_->start_resolve(host, service);
|
impl_->start_resolve(host, service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
session::session(boost::asio::io_service &io_service,
|
||||||
|
const boost::asio::ip::tcp::endpoint &local_endpoint,
|
||||||
|
const std::string &host, const std::string &service,
|
||||||
|
const boost::posix_time::time_duration &connect_timeout)
|
||||||
|
: impl_(std::make_shared<session_tcp_impl>(io_service, local_endpoint, host,
|
||||||
|
service, connect_timeout)) {
|
||||||
|
impl_->start_resolve(host, service);
|
||||||
|
}
|
||||||
|
|
||||||
session::session(boost::asio::io_service &io_service,
|
session::session(boost::asio::io_service &io_service,
|
||||||
boost::asio::ssl::context &tls_ctx, const std::string &host,
|
boost::asio::ssl::context &tls_ctx, const std::string &host,
|
||||||
const std::string &service)
|
const std::string &service)
|
||||||
|
|
|
@ -34,24 +34,31 @@ session_tcp_impl::session_tcp_impl(
|
||||||
const boost::posix_time::time_duration &connect_timeout)
|
const boost::posix_time::time_duration &connect_timeout)
|
||||||
: session_impl(io_service, connect_timeout), socket_(io_service) {}
|
: session_impl(io_service, connect_timeout), socket_(io_service) {}
|
||||||
|
|
||||||
|
session_tcp_impl::session_tcp_impl(
|
||||||
|
boost::asio::io_service &io_service,
|
||||||
|
const boost::asio::ip::tcp::endpoint &local_endpoint,
|
||||||
|
const std::string &host, const std::string &service,
|
||||||
|
const boost::posix_time::time_duration &connect_timeout)
|
||||||
|
: session_impl(io_service, connect_timeout),
|
||||||
|
socket_(io_service, local_endpoint) {}
|
||||||
|
|
||||||
session_tcp_impl::~session_tcp_impl() {}
|
session_tcp_impl::~session_tcp_impl() {}
|
||||||
|
|
||||||
void session_tcp_impl::start_connect(tcp::resolver::iterator endpoint_it) {
|
void session_tcp_impl::start_connect(tcp::resolver::iterator endpoint_it) {
|
||||||
auto self = shared_from_this();
|
auto self = shared_from_this();
|
||||||
boost::asio::async_connect(socket_, endpoint_it,
|
socket_.async_connect(
|
||||||
[self](const boost::system::error_code &ec,
|
*endpoint_it, [self, endpoint_it](const boost::system::error_code &ec) {
|
||||||
tcp::resolver::iterator endpoint_it) {
|
if (self->stopped()) {
|
||||||
if (self->stopped()) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (ec) {
|
if (ec) {
|
||||||
self->not_connected(ec);
|
self->not_connected(ec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self->connected(endpoint_it);
|
self->connected(endpoint_it);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
tcp::socket &session_tcp_impl::socket() { return socket_; }
|
tcp::socket &session_tcp_impl::socket() { return socket_; }
|
||||||
|
|
|
@ -40,6 +40,10 @@ public:
|
||||||
session_tcp_impl(boost::asio::io_service &io_service, const std::string &host,
|
session_tcp_impl(boost::asio::io_service &io_service, const std::string &host,
|
||||||
const std::string &service,
|
const std::string &service,
|
||||||
const boost::posix_time::time_duration &connect_timeout);
|
const boost::posix_time::time_duration &connect_timeout);
|
||||||
|
session_tcp_impl(boost::asio::io_service &io_service,
|
||||||
|
const boost::asio::ip::tcp::endpoint &local_endpoint,
|
||||||
|
const std::string &host, const std::string &service,
|
||||||
|
const boost::posix_time::time_duration &connect_timeout);
|
||||||
virtual ~session_tcp_impl();
|
virtual ~session_tcp_impl();
|
||||||
|
|
||||||
virtual void start_connect(tcp::resolver::iterator endpoint_it);
|
virtual void start_connect(tcp::resolver::iterator endpoint_it);
|
||||||
|
|
|
@ -150,6 +150,11 @@ public:
|
||||||
session(boost::asio::io_service &io_service, const std::string &host,
|
session(boost::asio::io_service &io_service, const std::string &host,
|
||||||
const std::string &service);
|
const std::string &service);
|
||||||
|
|
||||||
|
// Same as previous but with pegged local endpoint
|
||||||
|
session(boost::asio::io_service &io_service,
|
||||||
|
const boost::asio::ip::tcp::endpoint &local_endpoint,
|
||||||
|
const std::string &host, const std::string &service);
|
||||||
|
|
||||||
// Starts HTTP/2 session by connecting to |host| and |service|
|
// Starts HTTP/2 session by connecting to |host| and |service|
|
||||||
// (e.g., "80") using clear text TCP connection with given connect
|
// (e.g., "80") using clear text TCP connection with given connect
|
||||||
// timeout.
|
// timeout.
|
||||||
|
@ -157,6 +162,12 @@ public:
|
||||||
const std::string &service,
|
const std::string &service,
|
||||||
const boost::posix_time::time_duration &connect_timeout);
|
const boost::posix_time::time_duration &connect_timeout);
|
||||||
|
|
||||||
|
// Same as previous but with pegged local endpoint
|
||||||
|
session(boost::asio::io_service &io_service,
|
||||||
|
const boost::asio::ip::tcp::endpoint &local_endpoint,
|
||||||
|
const std::string &host, const std::string &service,
|
||||||
|
const boost::posix_time::time_duration &connect_timeout);
|
||||||
|
|
||||||
// Starts HTTP/2 session by connecting to |host| and |service|
|
// Starts HTTP/2 session by connecting to |host| and |service|
|
||||||
// (e.g., "443") using encrypted SSL/TLS connection with connect
|
// (e.g., "443") using encrypted SSL/TLS connection with connect
|
||||||
// timeout 60 seconds.
|
// timeout 60 seconds.
|
||||||
|
|
Loading…
Reference in New Issue