Interface HttpClient

    • Method Detail

      • 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 asynchronously
        type - 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 body

        HtttpClient implementations will provide ByteBuffers that may be held directly.

        Parameters:
        request - the HttpRequest to send
        consumer - the response body consumer
        Returns:
        the future which will be ready after the headers have been read
      • isClosed

        boolean isClosed()