Skip to content

Commit

Permalink
allow loopback server and client to work without an interface address (
Browse files Browse the repository at this point in the history
…microsoft#5)

Co-authored-by: rmyers808 <[email protected]>
  • Loading branch information
rmyers808 and rmyers808 authored May 17, 2023
1 parent cfcdbbf commit bbc36f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions Release/src/http/client/http_client_asio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,8 @@ class asio_context final : public request_context, public std::enable_shared_fro

m_context->m_timer.start();

tcp::resolver::query query(utility::conversions::to_utf8string(proxy_host), to_string(proxy_port));
// Allow client to work on loopback address overriding default asio address_configured flag
tcp::resolver::query query(utility::conversions::to_utf8string(proxy_host), to_string(proxy_port), boost::asio::ip::resolver_query_base::flags());

auto client = std::static_pointer_cast<asio_client>(m_context->m_http_client);
client->m_resolver.async_resolve(query,
Expand Down Expand Up @@ -869,7 +870,8 @@ class asio_context final : public request_context, public std::enable_shared_fro
auto tcp_host = proxy_type == http_proxy_type::http ? proxy_host : host;
auto tcp_port = proxy_type == http_proxy_type::http ? proxy_port : port;

tcp::resolver::query query(tcp_host, to_string(tcp_port));
// Allow client to work on loopback address overriding default asio address_configured flag
tcp::resolver::query query(tcp_host, to_string(tcp_port), boost::asio::ip::resolver_query_base::flags());
auto client = std::static_pointer_cast<asio_client>(ctx->m_http_client);
client->m_resolver.async_resolve(query,
boost::bind(&asio_context::handle_resolve,
Expand Down
7 changes: 5 additions & 2 deletions Release/src/http/listener/http_server_asio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,12 @@ void hostport_listener::start()
auto& service = crossplat::threadpool::shared_instance().service();
tcp::resolver resolver(service);
// #446: boost resolver does not recognize "+" as a host wildchar

// Merge release 1.14 change #1145
// Allow server to work on loopback address overriding default asio address_configured flag
tcp::resolver::query query = ( "+" == m_host)?
tcp::resolver::query(m_port):
tcp::resolver::query(m_host, m_port);
tcp::resolver::query(m_port, boost::asio::ip::resolver_query_base::flags()):
tcp::resolver::query(m_host, m_port, boost::asio::ip::resolver_query_base::flags());

tcp::endpoint endpoint = *resolver.resolve(query);

Expand Down

0 comments on commit bbc36f7

Please sign in to comment.