From 0289582a5d6ab048309c65cb5218bf57256e78e6 Mon Sep 17 00:00:00 2001 From: Harald Musum Date: Mon, 2 May 2022 20:24:04 +0200 Subject: Revert "Remove another HTTP client wrapper" --- .../java/ai/vespa/hosted/client/AbstractHttpClient.java | 4 ++-- .../src/main/java/ai/vespa/hosted/client/HttpClient.java | 15 ++------------- 2 files changed, 4 insertions(+), 15 deletions(-) (limited to 'http-client') diff --git a/http-client/src/main/java/ai/vespa/hosted/client/AbstractHttpClient.java b/http-client/src/main/java/ai/vespa/hosted/client/AbstractHttpClient.java index ed3fee101ed..6a76ef65082 100644 --- a/http-client/src/main/java/ai/vespa/hosted/client/AbstractHttpClient.java +++ b/http-client/src/main/java/ai/vespa/hosted/client/AbstractHttpClient.java @@ -147,10 +147,10 @@ public abstract class AbstractHttpClient implements HttpClient { private final Method method; private final HostStrategy hosts; - private final List> dynamicQuery = new ArrayList<>(); - private final Map> headers = new LinkedHashMap<>(); private HttpURL.Path path = Path.empty(); private HttpURL.Query query = Query.empty(); + private List> dynamicQuery = new ArrayList<>(); + private Map> headers = new LinkedHashMap<>(); private Supplier entity = () -> null; private RequestConfig config = HttpClient.defaultRequestConfig; private ResponseVerifier verifier = HttpClient.throwOnError; diff --git a/http-client/src/main/java/ai/vespa/hosted/client/HttpClient.java b/http-client/src/main/java/ai/vespa/hosted/client/HttpClient.java index ea8328ed793..16a419bf324 100644 --- a/http-client/src/main/java/ai/vespa/hosted/client/HttpClient.java +++ b/http-client/src/main/java/ai/vespa/hosted/client/HttpClient.java @@ -226,8 +226,7 @@ public interface HttpClient extends Closeable { @Override default RuntimeException toException(int statusCode, byte[] body, ClassicHttpRequest request) { - return new ResponseException(statusCode, - request + " failed with status " + statusCode + " and body '" + new String(body, UTF_8) + "'"); + return new ResponseException(request + " failed with status " + statusCode + " and body '" + new String(body, UTF_8) + "'"); } } @@ -250,11 +249,6 @@ public interface HttpClient extends Closeable { @FunctionalInterface interface HostStrategy extends Iterable { - /** Attempts the given host once. */ - static HostStrategy of(URI host) { - return repeating(host, 1); - } - /** Attempts each request once against each listed host. */ static HostStrategy ordered(List hosts) { return List.copyOf(hosts)::iterator; @@ -298,15 +292,10 @@ public interface HttpClient extends Closeable { /** An exception due to server error, a bad request, or similar, which resulted in a non-OK HTTP response. */ class ResponseException extends RuntimeException { - private final int statusCode; - - public ResponseException(int statusCode, String message) { + public ResponseException(String message) { super(message); - this.statusCode = statusCode; } - public int statusCode() { return statusCode; } - } } \ No newline at end of file -- cgit v1.2.3