Interface HttpClient
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
StandardHttpClient
public interface HttpClient extends AutoCloseable
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
HttpClient.Builder
static interface
HttpClient.DerivedClientBuilder
static interface
HttpClient.Factory
static class
HttpClient.ProxyType
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
CompletableFuture<HttpResponse<AsyncBody>>
consumeBytes(HttpRequest request, AsyncBody.Consumer<List<ByteBuffer>> consumer)
Send a request and consume the bytes of the resulting response bodyboolean
isClosed()
HttpClient.DerivedClientBuilder
newBuilder()
Create a builder that starts with the same state as this client.HttpRequest.Builder
newHttpRequestBuilder()
WebSocket.Builder
newWebSocketBuilder()
<T> CompletableFuture<HttpResponse<T>>
sendAsync(HttpRequest request, Class<T> type)
Send an async request
A Reader or InputStream result must be closed by the caller to properly cleanup resources.
-
-
-
Method Detail
-
close
void close()
- Specified by:
close
in interfaceAutoCloseable
-
newBuilder
HttpClient.DerivedClientBuilder newBuilder()
Create a builder that starts with the same state as this client.
The client resources will be shared across derived instances.- Returns:
- a new builder
-
sendAsync
<T> CompletableFuture<HttpResponse<T>> sendAsync(HttpRequest request, Class<T> type)
Send an async request
A Reader or InputStream result must be closed by the caller to properly cleanup resources.
A Reader or InputStream result should not be consumed by the thread completing the returned future as that will hijack a client thread.- Type Parameters:
T
- return type- Parameters:
request
- the HttpRequest to send asynchronouslytype
- one of InputStream, Reader, String, byte[]- Returns:
- a CompletableFuture that returns the resulting HttpResponse when complete
-
consumeBytes
CompletableFuture<HttpResponse<AsyncBody>> consumeBytes(HttpRequest request, AsyncBody.Consumer<List<ByteBuffer>> consumer)
Send a request and consume the bytes of the resulting response bodyHtttpClient implementations will provide ByteBuffers that may be held directly.
- Parameters:
request
- the HttpRequest to sendconsumer
- the response body consumer- Returns:
- the future which will be ready after the headers have been read
-
newWebSocketBuilder
WebSocket.Builder newWebSocketBuilder()
-
newHttpRequestBuilder
HttpRequest.Builder newHttpRequestBuilder()
-
isClosed
boolean isClosed()
-
-