Skip to content

Commit 02b8718

Browse files
committed
if ssl_context_callback is used, then the pool is not added to the map
1 parent 6e23e69 commit 02b8718

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

Release/src/http/client/http_client_asio.cpp

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -338,31 +338,42 @@ class asio_client : public _http_client_communicator
338338
: _http_client_communicator(std::move(address), std::move(client_config))
339339
, m_resolver(crossplat::threadpool::shared_instance().service())
340340
{
341-
std::string host = base_uri().to_string();
342-
343-
auto &credentials = _http_client_communicator::client_config().credentials();
344-
if (credentials.is_set())
341+
if (this->client_config().get_ssl_context_callback())
345342
{
346-
host.append(credentials.username());
343+
// The pool is not added to the map because there is no better approaches to compare callback functors.
344+
m_pool = std::make_shared<asio_connection_pool>(crossplat::threadpool::shared_instance().service(),
345+
base_uri().scheme() == "https" && !_http_client_communicator::client_config().proxy().is_specified(),
346+
std::chrono::seconds(30), // Unused sockets are kept in pool for 30 seconds.
347+
this->client_config().get_ssl_context_callback());
347348
}
348-
349-
auto &proxy = _http_client_communicator::client_config().proxy();
350-
if (proxy.is_specified())
349+
else
351350
{
352-
host.append(proxy.address().to_string());
353-
if (proxy.credentials().is_set())
351+
std::string host = base_uri().to_string();
352+
353+
auto &credentials = _http_client_communicator::client_config().credentials();
354+
if (credentials.is_set())
354355
{
355-
host.append(proxy.credentials().username());
356+
host.append(credentials.username());
356357
}
357-
}
358358

359-
m_pool = crossplat::threadpool::shared_instance().obtain_connection_pool(host, [this]()
360-
{
361-
return std::make_shared<asio_connection_pool>(crossplat::threadpool::shared_instance().service(),
362-
base_uri().scheme() == "https" && !_http_client_communicator::client_config().proxy().is_specified(),
363-
std::chrono::seconds(30), // Unused sockets are kept in pool for 30 seconds.
364-
this->client_config().get_ssl_context_callback());
365-
});
359+
auto &proxy = _http_client_communicator::client_config().proxy();
360+
if (proxy.is_specified())
361+
{
362+
host.append(proxy.address().to_string());
363+
if (proxy.credentials().is_set())
364+
{
365+
host.append(proxy.credentials().username());
366+
}
367+
}
368+
369+
m_pool = crossplat::threadpool::shared_instance().obtain_connection_pool(host, [this]()
370+
{
371+
return std::make_shared<asio_connection_pool>(crossplat::threadpool::shared_instance().service(),
372+
base_uri().scheme() == "https" && !_http_client_communicator::client_config().proxy().is_specified(),
373+
std::chrono::seconds(30), // Unused sockets are kept in pool for 30 seconds.
374+
this->client_config().get_ssl_context_callback());
375+
});
376+
}
366377
}
367378

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

0 commit comments

Comments
 (0)