Skip to content
Snippets Groups Projects
Unverified Commit df27e71a authored by Sébastien Blin's avatar Sébastien Blin
Browse files

proxy: resolve url with protocol and port

parent 769ce457
Branches fix/proto2
No related tags found
No related merge requests found
...@@ -527,7 +527,14 @@ DhtProxyClient::getProxyInfos() ...@@ -527,7 +527,14 @@ DhtProxyClient::getProxyInfos()
} }
statusThread_ = std::thread([this, serverHost, infoState]{ statusThread_ = std::thread([this, serverHost, infoState]{
try { try {
auto hostAndService = splitPort(serverHost); auto endpointStr = serverHost;
auto protocol = std::string(proxy::HTTP_PROTO);
auto protocolIdx = serverHost.find("://");
if (protocolIdx != std::string::npos) {
protocol = endpointStr.substr(0, protocolIdx + 3);
endpointStr = endpointStr.substr(protocolIdx + 3);
}
auto hostAndService = splitPort(endpointStr);
auto resolved_proxies = SockAddr::resolve(hostAndService.first, hostAndService.second); auto resolved_proxies = SockAddr::resolve(hostAndService.first, hostAndService.second);
std::vector<std::future<Sp<restbed::Response>>> reqs; std::vector<std::future<Sp<restbed::Response>>> reqs;
reqs.reserve(resolved_proxies.size()); reqs.reserve(resolved_proxies.size());
...@@ -536,9 +543,9 @@ DhtProxyClient::getProxyInfos() ...@@ -536,9 +543,9 @@ DhtProxyClient::getProxyInfos()
if (resolved_proxy.getFamily() == AF_INET6) { if (resolved_proxy.getFamily() == AF_INET6) {
// HACK restbed seems to not correctly handle directly http://[ipv6] // HACK restbed seems to not correctly handle directly http://[ipv6]
// See https://github.com/Corvusoft/restbed/issues/290. // See https://github.com/Corvusoft/restbed/issues/290.
server = serverHost; server = endpointStr;
} }
restbed::Uri uri(proxy::HTTP_PROTO + server + "/"); restbed::Uri uri(protocol + server + "/");
auto req = std::make_shared<restbed::Request>(uri); auto req = std::make_shared<restbed::Request>(uri);
if (infoState->cancel) if (infoState->cancel)
return; return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment