public interface HttpClient extends java.io.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(java.net.URL url)
Create a new
HttpClient . |
static HttpClient |
create(java.net.URL url,
HttpClientConfiguration configuration)
Create a new
HttpClient with the specified configuration. |
default <I> org.reactivestreams.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> org.reactivestreams.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> org.reactivestreams.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> org.reactivestreams.Publisher<HttpResponse<O>> |
exchange(HttpRequest<I> request,
java.lang.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 org.reactivestreams.Publisher<HttpResponse<ByteBuffer>> |
exchange(java.lang.String uri)
Perform an HTTP GET request for the given request object emitting the full HTTP response from returned
Publisher . |
default <O> org.reactivestreams.Publisher<HttpResponse<O>> |
exchange(java.lang.String uri,
java.lang.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> org.reactivestreams.Publisher<java.lang.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> org.reactivestreams.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> org.reactivestreams.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> org.reactivestreams.Publisher<O> |
retrieve(HttpRequest<I> request,
java.lang.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 org.reactivestreams.Publisher<java.lang.String> |
retrieve(java.lang.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> org.reactivestreams.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> org.reactivestreams.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> org.reactivestreams.Publisher<HttpResponse<ByteBuffer>> exchange(@NonNull HttpRequest<I> request)
Publisher
.I
- The request body typerequest
- The HttpRequest
to executePublisher
that emits the full HttpResponse
objectdefault org.reactivestreams.Publisher<HttpResponse<ByteBuffer>> exchange(@NonNull java.lang.String uri)
Publisher
.uri
- The UriPublisher
that emits the full HttpResponse
objectdefault <O> org.reactivestreams.Publisher<HttpResponse<O>> exchange(@NonNull java.lang.String uri, @NonNull java.lang.Class<O> bodyType)
Publisher
.O
- The response body typeuri
- The request URIbodyType
- The body typePublisher
that emits the full HttpResponse
objectdefault <I,O> org.reactivestreams.Publisher<HttpResponse<O>> exchange(@NonNull HttpRequest<I> request, @NonNull java.lang.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> org.reactivestreams.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> org.reactivestreams.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> org.reactivestreams.Publisher<O> retrieve(@NonNull HttpRequest<I> request, @NonNull java.lang.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> org.reactivestreams.Publisher<java.lang.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 org.reactivestreams.Publisher<java.lang.String> retrieve(@NonNull java.lang.String uri)
Publisher
and converting the response body to the specified type.uri
- The URIPublisher
that emits String resultdefault HttpClient refresh()
LifeCycle
LifeCycle.stop()
followed by LifeCycle.start()
.refresh
in interface LifeCycle<HttpClient>
static HttpClient create(@Nullable java.net.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 java.net.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