@@ -474,7 +474,6 @@ class asio_client final : public _http_client_communicator
474
474
public:
475
475
asio_client (http::uri&& address, http_client_config&& client_config)
476
476
: _http_client_communicator(std::move(address), std::move(client_config))
477
- , m_resolver(crossplat::threadpool::shared_instance().service())
478
477
, m_pool(std::make_shared<asio_connection_pool>())
479
478
{
480
479
}
@@ -502,8 +501,6 @@ class asio_client final : public _http_client_communicator
502
501
503
502
virtual pplx::task<http_response> propagate (http_request request) override ;
504
503
505
- tcp::resolver m_resolver;
506
-
507
504
private:
508
505
const std::shared_ptr<asio_connection_pool> m_pool;
509
506
};
@@ -520,6 +517,7 @@ class asio_context final : public request_context, public std::enable_shared_fro
520
517
, m_content_length(0 )
521
518
, m_needChunked(false )
522
519
, m_timer(client->client_config ().timeout<std::chrono::microseconds>())
520
+ , m_resolver(crossplat::threadpool::shared_instance().service())
523
521
, m_connection(connection)
524
522
#ifdef CPPREST_PLATFORM_ASIO_CERT_VERIFICATION_AVAILABLE
525
523
, m_openssl_failed(false )
@@ -585,11 +583,11 @@ class asio_context final : public request_context, public std::enable_shared_fro
585
583
tcp::resolver::query query (utility::conversions::to_utf8string (proxy_host), to_string (proxy_port));
586
584
587
585
auto client = std::static_pointer_cast<asio_client>(m_context->m_http_client );
588
- client ->m_resolver .async_resolve (query,
589
- boost::bind (&ssl_proxy_tunnel::handle_resolve,
590
- shared_from_this (),
591
- boost::asio::placeholders::error,
592
- boost::asio::placeholders::iterator));
586
+ m_context ->m_resolver .async_resolve (query,
587
+ boost::bind (&ssl_proxy_tunnel::handle_resolve,
588
+ shared_from_this (),
589
+ boost::asio::placeholders::error,
590
+ boost::asio::placeholders::iterator));
593
591
}
594
592
595
593
private:
@@ -887,12 +885,11 @@ class asio_context final : public request_context, public std::enable_shared_fro
887
885
auto tcp_port = proxy_type == http_proxy_type::http ? proxy_port : port;
888
886
889
887
tcp::resolver::query query (tcp_host, to_string (tcp_port));
890
- auto client = std::static_pointer_cast<asio_client>(ctx->m_http_client );
891
- client->m_resolver .async_resolve (query,
892
- boost::bind (&asio_context::handle_resolve,
893
- ctx,
894
- boost::asio::placeholders::error,
895
- boost::asio::placeholders::iterator));
888
+ ctx->m_resolver .async_resolve (query,
889
+ boost::bind (&asio_context::handle_resolve,
890
+ ctx,
891
+ boost::asio::placeholders::error,
892
+ boost::asio::placeholders::iterator));
896
893
}
897
894
898
895
// Register for notification on cancellation to abort this request.
@@ -1053,6 +1050,10 @@ class asio_context final : public request_context, public std::enable_shared_fro
1053
1050
{
1054
1051
report_error (" Error resolving address" , ec, httpclient_errorcode_context::connect);
1055
1052
}
1053
+ else if (endpoints == tcp::resolver::iterator ())
1054
+ {
1055
+ report_error (" Failed to resolve address" , ec, httpclient_errorcode_context::connect);
1056
+ }
1056
1057
else
1057
1058
{
1058
1059
m_timer.reset ();
@@ -1452,8 +1453,8 @@ class asio_context final : public request_context, public std::enable_shared_fro
1452
1453
}
1453
1454
}
1454
1455
1455
- m_content_length = (std::numeric_limits<size_t >::max)(); // Without Content-Length header, size should be same as
1456
- // TCP stream - set it size_t max.
1456
+ m_content_length = (std::numeric_limits<size_t >::max)(); // Without Content-Length header, size should be same
1457
+ // as TCP stream - set it size_t max.
1457
1458
m_response.headers ().match (header_names::content_length, m_content_length);
1458
1459
1459
1460
if (!this ->handle_compression ())
@@ -1936,6 +1937,7 @@ class asio_context final : public request_context, public std::enable_shared_fro
1936
1937
uint64_t m_content_length;
1937
1938
bool m_needChunked;
1938
1939
timeout_timer m_timer;
1940
+ tcp::resolver m_resolver;
1939
1941
boost::asio::streambuf m_body_buf;
1940
1942
std::shared_ptr<asio_connection> m_connection;
1941
1943
0 commit comments