aboutsummaryrefslogtreecommitdiffstats
path: root/http-client/src/main/java/ai/vespa/hosted/client/HttpClient.java
diff options
context:
space:
mode:
Diffstat (limited to 'http-client/src/main/java/ai/vespa/hosted/client/HttpClient.java')
-rw-r--r--http-client/src/main/java/ai/vespa/hosted/client/HttpClient.java6
1 files changed, 6 insertions, 0 deletions
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}. */