Skip to content

Commit

Permalink
if ssl_context_callback is used, then the pool is not added to the map
Browse files Browse the repository at this point in the history
  • Loading branch information
hanzhumsft committed May 18, 2016
1 parent 6e23e69 commit 02b8718
Showing 1 changed file with 30 additions and 19 deletions.
49 changes: 30 additions & 19 deletions Release/src/http/client/http_client_asio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,31 +338,42 @@ class asio_client : public _http_client_communicator
: _http_client_communicator(std::move(address), std::move(client_config))
, m_resolver(crossplat::threadpool::shared_instance().service())
{
std::string host = base_uri().to_string();

auto &credentials = _http_client_communicator::client_config().credentials();
if (credentials.is_set())
if (this->client_config().get_ssl_context_callback())
{
host.append(credentials.username());
// The pool is not added to the map because there is no better approaches to compare callback functors.
m_pool = std::make_shared<asio_connection_pool>(crossplat::threadpool::shared_instance().service(),
base_uri().scheme() == "https" && !_http_client_communicator::client_config().proxy().is_specified(),
std::chrono::seconds(30), // Unused sockets are kept in pool for 30 seconds.
this->client_config().get_ssl_context_callback());
}

auto &proxy = _http_client_communicator::client_config().proxy();
if (proxy.is_specified())
else
{
host.append(proxy.address().to_string());
if (proxy.credentials().is_set())
std::string host = base_uri().to_string();

auto &credentials = _http_client_communicator::client_config().credentials();
if (credentials.is_set())
{
host.append(proxy.credentials().username());
host.append(credentials.username());
}
}

m_pool = crossplat::threadpool::shared_instance().obtain_connection_pool(host, [this]()
{
return std::make_shared<asio_connection_pool>(crossplat::threadpool::shared_instance().service(),
base_uri().scheme() == "https" && !_http_client_communicator::client_config().proxy().is_specified(),
std::chrono::seconds(30), // Unused sockets are kept in pool for 30 seconds.
this->client_config().get_ssl_context_callback());
});
auto &proxy = _http_client_communicator::client_config().proxy();
if (proxy.is_specified())
{
host.append(proxy.address().to_string());
if (proxy.credentials().is_set())
{
host.append(proxy.credentials().username());
}
}

m_pool = crossplat::threadpool::shared_instance().obtain_connection_pool(host, [this]()
{
return std::make_shared<asio_connection_pool>(crossplat::threadpool::shared_instance().service(),
base_uri().scheme() == "https" && !_http_client_communicator::client_config().proxy().is_specified(),
std::chrono::seconds(30), // Unused sockets are kept in pool for 30 seconds.
this->client_config().get_ssl_context_callback());
});
}
}

void send_request(const std::shared_ptr<request_context> &request_ctx) override;
Expand Down

0 comments on commit 02b8718

Please sign in to comment.