aboutsummaryrefslogtreecommitdiffstats
path: root/http-client
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2022-11-04 22:46:07 +0100
committerjonmv <venstad@gmail.com>2022-11-04 22:46:07 +0100
commit25bc8d1f050942ed29273b46efe0f7b2b0432045 (patch)
treedc27af3e69680611e41c56d688d9f1be4971129f /http-client
parent070c4b8060b622b5a10dead98a902cb4850610dc (diff)
Revert "Merge pull request #24725 from vespa-engine/jonmv/application-package-streams"
This reverts commit c7a0effde1c205d8790e5d989437aefd724bc70f, reversing changes made to 7bcb7768d75c1eef5bc70a2aa84c363f9b7ec643.
Diffstat (limited to 'http-client')
-rw-r--r--http-client/src/main/java/ai/vespa/hosted/client/AbstractHttpClient.java2
-rw-r--r--http-client/src/main/java/ai/vespa/hosted/client/HttpClient.java6
2 files changed, 7 insertions, 1 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 48bbffc7e37..ed3fee101ed 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
@@ -173,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 4da887f0cbb..ea8328ed793 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,6 +78,12 @@ 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("entitiy 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}. */