From 80f04430c3a30d74a017f972280f51b207cc17b6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Wed, 30 Oct 2019 14:53:07 -0400
Subject: [PATCH] proxy client: build resolver if none available

---
 src/dht_proxy_client.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/dht_proxy_client.cpp b/src/dht_proxy_client.cpp
index 2406dac3..d026619d 100644
--- a/src/dht_proxy_client.cpp
+++ b/src/dht_proxy_client.cpp
@@ -411,9 +411,12 @@ DhtProxyClient::handleRefreshPut(const asio::error_code &ec, const InfoHash& key
 std::shared_ptr<http::Request>
 DhtProxyClient::buildRequest(const std::string& target)
 {
+    auto resolver = resolver_;
+    if (not resolver)
+        resolver = std::make_shared<http::Resolver>(httpContext_, proxyUrl_, logger_);
     auto request = target.empty() 
-        ? std::make_shared<http::Request>(httpContext_, resolver_)
-        : std::make_shared<http::Request>(httpContext_, resolver_, target);
+        ? std::make_shared<http::Request>(httpContext_, resolver)
+        : std::make_shared<http::Request>(httpContext_, resolver, target);
     if (serverCertificate_)
         request->set_certificate_authority(serverCertificate_);
     if (clientIdentity_.first and clientIdentity_.second)
-- 
GitLab