@Incubating
final class HttpBuilder
extends Object
Tiny DSL over JDK HttpClient.
| Modifiers | Name | Description |
|---|---|---|
static class |
HttpBuilder.Config |
Configuration DSL used to create an HttpBuilder. |
static class |
HttpBuilder.RequestSpec |
Per-request configuration DSL used by the request methods. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
HttpResult |
delete(Object uri, Closure<?> spec)Executes a synchronous DELETE request. |
|
CompletableFuture<HttpResult> |
deleteAsync(Object uri, Closure<?> spec)Executes an asynchronous DELETE request. |
|
HttpResult |
get(Object uri, Closure<?> spec)Executes a synchronous GET request. |
|
CompletableFuture<HttpResult> |
getAsync(Object uri, Closure<?> spec)Executes an asynchronous GET request. |
|
CompletableFuture<HttpStreamResult> |
getStreamAsync(Object uri, Closure<?> spec)Executes an asynchronous streaming GET request. |
|
static HttpBuilder |
http(Closure<?> spec)Creates an HttpBuilder from the supplied configuration closure. |
|
static HttpBuilder |
http(String baseUri)Creates an HttpBuilder with only a base URI configured. |
|
HttpResult |
patch(Object uri, Closure<?> spec)Executes a synchronous PATCH request. |
|
CompletableFuture<HttpResult> |
patchAsync(Object uri, Closure<?> spec)Executes an asynchronous PATCH request. |
|
HttpResult |
post(Object uri, Closure<?> spec)Executes a synchronous POST request. |
|
CompletableFuture<HttpResult> |
postAsync(Object uri, Closure<?> spec)Executes an asynchronous POST request. |
|
CompletableFuture<HttpStreamResult> |
postStreamAsync(Object uri, Closure<?> spec)Executes an asynchronous streaming POST request. |
|
HttpResult |
put(Object uri, Closure<?> spec)Executes a synchronous PUT request. |
|
CompletableFuture<HttpResult> |
putAsync(Object uri, Closure<?> spec)Executes an asynchronous PUT request. |
|
HttpResult |
request(String method, Object uri, Closure<?> spec)Executes a synchronous request with the supplied HTTP method. |
|
CompletableFuture<HttpResult> |
requestAsync(String method, Object uri, Closure<?> spec)Executes an asynchronous request with the supplied HTTP method. |
|
CompletableFuture<HttpStreamResult> |
streamAsync(String method, Object uri, Closure<?> spec)Streams the response body without buffering. |
Executes a synchronous DELETE request.
uri - the absolute or base-relative request URIspec - optionally customizes the request Executes an asynchronous DELETE request.
uri - the absolute or base-relative request URIspec - optionally customizes the request Executes a synchronous GET request.
uri - the absolute or base-relative request URIspec - optionally customizes the request Executes an asynchronous GET request.
uri - the absolute or base-relative request URIspec - optionally customizes the request Executes an asynchronous streaming GET request.
uri - the absolute or base-relative request URIspec - optionally customizes the request Creates an HttpBuilder from the supplied configuration closure.
spec - configures the builder defaults Creates an HttpBuilder with only a base URI configured.
baseUri - the absolute base URI used to resolve relative requests Executes a synchronous PATCH request.
uri - the absolute or base-relative request URIspec - optionally customizes the request Executes an asynchronous PATCH request.
uri - the absolute or base-relative request URIspec - optionally customizes the request Executes a synchronous POST request.
uri - the absolute or base-relative request URIspec - optionally customizes the request Executes an asynchronous POST request.
uri - the absolute or base-relative request URIspec - optionally customizes the request Executes an asynchronous streaming POST request.
uri - the absolute or base-relative request URIspec - optionally customizes the request Executes a synchronous PUT request.
uri - the absolute or base-relative request URIspec - optionally customizes the request Executes an asynchronous PUT request.
uri - the absolute or base-relative request URIspec - optionally customizes the requestExecutes a synchronous request with the supplied HTTP method.
method - the HTTP method to useuri - the absolute or base-relative request URIspec - optionally customizes the requestExecutes an asynchronous request with the supplied HTTP method.
method - the HTTP method to useuri - the absolute or base-relative request URIspec - optionally customizes the request Streams the response body without buffering. Returns an
HttpStreamResult whose bodyAsPublisher() delivers
List<ByteBuffer> chunks as they arrive — enabling
for await (chunk in result.bodyAsPublisher()) via the
FlowPublisherAdapter.
Streaming always uses HttpResponse.BodyHandlers.ofPublisher();
any bodyHandler configured on the RequestSpec is ignored.
method - the HTTP method to useuri - the absolute or base-relative request URIspec - optionally customizes the request