public interface HttpClient extends Closeable, LifeCycle<HttpClient>
| Modifier and Type | Field and Description |
|---|---|
static Argument<JsonError> |
DEFAULT_ERROR_TYPE
The default error type.
|
| Modifier and Type | Method and Description |
|---|---|
static HttpClient |
create(URL url)
Create a new
HttpClient. |
static HttpClient |
create(URL url,
HttpClientConfiguration configuration)
Create a new
HttpClient with the specified configuration. |
default <I> Publisher<HttpResponse<ByteBuffer>> |
exchange(HttpRequest<I> request)
Perform an HTTP request for the given request object emitting the full HTTP response from returned
Publisher. |
default <I,O> Publisher<HttpResponse<O>> |
exchange(HttpRequest<I> request,
Argument<O> bodyType)
Perform an HTTP request for the given request object emitting the full HTTP response from returned
Publisher and converting the response body to the specified type. |
<I,O,E> Publisher<HttpResponse<O>> |
exchange(HttpRequest<I> request,
Argument<O> bodyType,
Argument<E> errorType)
Perform an HTTP request for the given request object emitting the full HTTP response from returned
Publisher and converting the response body to the specified type. |
default <I,O> Publisher<HttpResponse<O>> |
exchange(HttpRequest<I> request,
Class<O> bodyType)
Perform an HTTP request for the given request object emitting the full HTTP response from returned
Publisher and converting the response body to the specified type. |
default Publisher<HttpResponse<ByteBuffer>> |
exchange(String uri)
Perform an HTTP GET request for the given request object emitting the full HTTP response from returned
Publisher. |
default <O> Publisher<HttpResponse<O>> |
exchange(String uri,
Class<O> bodyType)
Perform an HTTP GET request for the given request object emitting the full HTTP response from returned
Publisher. |
default HttpClient |
refresh()
Refreshes the current life cycle object.
|
default <I> Publisher<String> |
retrieve(HttpRequest<I> request)
Perform an HTTP request for the given request object emitting the full HTTP response from returned
Publisher and converting the response body to the specified type. |
default <I,O> Publisher<O> |
retrieve(HttpRequest<I> request,
Argument<O> bodyType)
Perform an HTTP request for the given request object emitting the full HTTP response from returned
Publisher and converting the response body to the specified type. |
default <I,O,E> Publisher<O> |
retrieve(HttpRequest<I> request,
Argument<O> bodyType,
Argument<E> errorType)
Perform an HTTP request for the given request object emitting the full HTTP response from returned
Publisher and converting the response body to the specified type. |
default <I,O> Publisher<O> |
retrieve(HttpRequest<I> request,
Class<O> bodyType)
Perform an HTTP request for the given request object emitting the full HTTP response from returned
Publisher and converting the response body to the specified type. |
default Publisher<String> |
retrieve(String uri)
Perform an HTTP GET request for the given request object emitting the full HTTP response from returned
Publisher and converting the response body to the specified type. |
BlockingHttpClient |
toBlocking() |
BlockingHttpClient toBlocking()
<I,O,E> Publisher<HttpResponse<O>> exchange(@NonNull HttpRequest<I> request, @NonNull Argument<O> bodyType, @NonNull Argument<E> errorType)
Perform an HTTP request for the given request object emitting the full HTTP response from returned
Publisher and converting the response body to the specified type.
This method will send a Content-Length header and except a content length header the response and is
designed for simple non-streaming exchanges of data
By default the exchange Content-Type is application/json, unless otherwise specified in the passed
HttpRequest
I - The request body typeO - The response body typeE - The error typerequest - The HttpRequest to executebodyType - The body typeerrorType - The error typePublisher that emits the full HttpResponse objectdefault <I,O> Publisher<HttpResponse<O>> exchange(@NonNull HttpRequest<I> request, @NonNull Argument<O> bodyType)
Perform an HTTP request for the given request object emitting the full HTTP response from returned
Publisher and converting the response body to the specified type.
This method will send a Content-Length header and except a content length header the response and is
designed for simple non-streaming exchanges of data
By default the exchange Content-Type is application/json, unless otherwise specified in the passed
HttpRequest
I - The request body typeO - The response body typerequest - The HttpRequest to executebodyType - The body typePublisher that emits the full HttpResponse objectdefault <I> Publisher<HttpResponse<ByteBuffer>> exchange(@NonNull HttpRequest<I> request)
Publisher.I - The request body typerequest - The HttpRequest to executePublisher that emits the full HttpResponse objectdefault Publisher<HttpResponse<ByteBuffer>> exchange(@NonNull String uri)
Publisher.uri - The UriPublisher that emits the full HttpResponse objectdefault <O> Publisher<HttpResponse<O>> exchange(@NonNull String uri, @NonNull Class<O> bodyType)
Publisher.O - The response body typeuri - The request URIbodyType - The body typePublisher that emits the full HttpResponse objectdefault <I,O> Publisher<HttpResponse<O>> exchange(@NonNull HttpRequest<I> request, @NonNull Class<O> bodyType)
Publisher and converting the response body to the specified type.I - The request body typeO - The response body typerequest - The HttpRequest to executebodyType - The body typePublisher that emits the full HttpResponse objectdefault <I,O,E> Publisher<O> retrieve(@NonNull HttpRequest<I> request, @NonNull Argument<O> bodyType, @NonNull Argument<E> errorType)
Publisher and converting the response body to the specified type.I - The request body typeO - The response body typeE - The error typerequest - The HttpRequest to executebodyType - The body typeerrorType - The error typePublisher that emits a result of the given typedefault <I,O> Publisher<O> retrieve(@NonNull HttpRequest<I> request, @NonNull Argument<O> bodyType)
Publisher and converting the response body to the specified type.I - The request body typeO - The response body typerequest - The HttpRequest to executebodyType - The body typePublisher that emits a result of the given typedefault <I,O> Publisher<O> retrieve(@NonNull HttpRequest<I> request, @NonNull Class<O> bodyType)
Publisher and converting the response body to the specified type.I - The request body typeO - The response body typerequest - The HttpRequest to executebodyType - The body typePublisher that emits a result of the given typedefault <I> Publisher<String> retrieve(@NonNull HttpRequest<I> request)
Publisher and converting the response body to the specified type.I - The request body typerequest - The HttpRequest to executePublisher that emits String resultdefault Publisher<String> retrieve(@NonNull String uri)
Publisher and converting the response body to the specified type.uri - The URIPublisher that emits String resultdefault HttpClient refresh()
LifeCycleLifeCycle.stop() followed by LifeCycle.start().refresh in interface LifeCycle<HttpClient>static HttpClient create(@Nullable URL url)
HttpClient.
Note that this method should only be used outside of the context of a Micronaut application.
The returned HttpClient is not subject to dependency injection.
The creator is responsible for closing the client to avoid leaking connections.
Within a Micronaut application use Inject to inject a client instead.url - The base URLstatic HttpClient create(@Nullable URL url, @NonNull HttpClientConfiguration configuration)
HttpClient with the specified configuration. Note that this method should only be used
outside of the context of an application. Within Micronaut use Inject to inject a client insteadurl - The base URLconfiguration - the client configuration