diff options
Diffstat (limited to 'configserver/src/main/java/com/yahoo/vespa/config/server/http/SimpleHttpFetcher.java')
-rw-r--r-- | configserver/src/main/java/com/yahoo/vespa/config/server/http/SimpleHttpFetcher.java | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/SimpleHttpFetcher.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/SimpleHttpFetcher.java index 25d87b5c940..a8dfe3700e7 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/SimpleHttpFetcher.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/SimpleHttpFetcher.java @@ -8,13 +8,14 @@ import org.apache.hc.client5.http.classic.methods.HttpGet; import org.apache.hc.client5.http.config.RequestConfig; import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.client5.http.impl.classic.HttpClientBuilder; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; import org.apache.hc.core5.http.HttpEntity; import org.apache.hc.core5.util.Timeout; import java.io.IOException; import java.net.SocketTimeoutException; import java.net.URI; -import java.time.Duration; import java.util.logging.Level; import java.util.logging.Logger; @@ -23,24 +24,23 @@ public class SimpleHttpFetcher implements HttpFetcher { private final CloseableHttpClient client; - public SimpleHttpFetcher(Duration connectTimeout) { this(connectTimeout, null); } + public SimpleHttpFetcher() { this(null); } - public SimpleHttpFetcher(Duration connectTimeout, NodeHostnameVerifier verifier) { - VespaHttpClientBuilder builder = VespaHttpClientBuilder.custom().connectTimeout(Timeout.of(connectTimeout)); - if (verifier != null) { - builder.hostnameVerifier(verifier::verify); - } - this.client = builder.buildClient(); + public SimpleHttpFetcher(NodeHostnameVerifier verifier) { + HttpClientBuilder b = verifier != null + ? VespaHttpClientBuilder.create(PoolingHttpClientConnectionManager::new, verifier::verify) + : VespaHttpClientBuilder.create(); + this.client = b.build(); } @Override - @SuppressWarnings("deprecation") public HttpResponse get(Params params, URI url) { try { HttpGet request = new HttpGet(url); request.addHeader("Connection", "Close"); request.setConfig( RequestConfig.custom() + .setConnectTimeout(Timeout.ofMilliseconds(params.readTimeoutMs)) .setResponseTimeout(Timeout.ofMilliseconds(params.readTimeoutMs)) .build()); try (CloseableHttpResponse response = client.execute(request)) { |