@@ -338,31 +338,42 @@ class asio_client : public _http_client_communicator
338
338
: _http_client_communicator(std::move(address), std::move(client_config))
339
339
, m_resolver(crossplat::threadpool::shared_instance().service())
340
340
{
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 ())
345
342
{
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 ());
347
348
}
348
-
349
- auto &proxy = _http_client_communicator::client_config ().proxy ();
350
- if (proxy.is_specified ())
349
+ else
351
350
{
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 ())
354
355
{
355
- host.append (proxy. credentials () .username ());
356
+ host.append (credentials.username ());
356
357
}
357
- }
358
358
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
+ }
366
377
}
367
378
368
379
void send_request (const std::shared_ptr<request_context> &request_ctx) override ;
0 commit comments