diff options
author | jonmv <venstad@gmail.com> | 2022-11-03 17:18:28 +0100 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2022-11-03 17:18:28 +0100 |
commit | 7770be4be840a227e1ba21e06a282065024107ba (patch) | |
tree | d9eb1a2481f2c479acf1a8428a1b5cd9ada8f54f /http-client | |
parent | eeebb065fa12b3afa2a8b7c25999b1bda28907a9 (diff) |
Enforce input suppliers in http client
Diffstat (limited to 'http-client')
-rw-r--r-- | http-client/src/main/java/ai/vespa/hosted/client/AbstractHttpClient.java | 3 | ||||
-rw-r--r-- | http-client/src/main/java/ai/vespa/hosted/client/HttpClient.java | 6 |
2 files changed, 1 insertions, 8 deletions
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 08ac3b54903..48bbffc7e37 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 @@ -18,7 +18,6 @@ import org.apache.hc.core5.http.io.entity.EntityUtils; import org.apache.hc.core5.http.io.entity.HttpEntities; import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; import org.apache.hc.core5.util.Timeout; -import sun.misc.Unsafe; import java.io.IOException; import java.io.UncheckedIOException; @@ -174,7 +173,7 @@ public abstract class AbstractHttpClient implements HttpClient { @Override public HttpClient.RequestBuilder body(byte[] json) { - return body(HttpEntities.create(json, ContentType.APPLICATION_JSON)); + return body(() -> HttpEntities.create(json, ContentType.APPLICATION_JSON)); } @Override 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 2e60260e4c0..4da887f0cbb 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 @@ -78,12 +78,6 @@ public interface HttpClient extends Closeable { RequestBuilder body(byte[] json); /** Sets the request body. */ - default RequestBuilder body(HttpEntity entity) { - if (entity.isRepeatable()) return body(() -> entity); - throw new IllegalArgumentException("entity must be repeatable, or a supplier must be used"); - } - - /** Sets the request body. */ RequestBuilder body(Supplier<HttpEntity> entity); /** Sets query parameters without a value, like {@code ?debug&recursive}. */ |