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 . |
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(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.
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(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.
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(HttpRequest<I> request)
Publisher
.I
- The request body typerequest
- The HttpRequest
to executePublisher
that emits the full HttpResponse
objectdefault Publisher<HttpResponse<ByteBuffer>> exchange(String uri)
Publisher
.uri
- The UriPublisher
that emits the full HttpResponse
objectdefault <O> Publisher<HttpResponse<O>> exchange(String uri, 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(HttpRequest<I> request, 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(HttpRequest<I> request, Argument<O> bodyType, 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(HttpRequest<I> request, 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(HttpRequest<I> request, 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(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(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(URL url)
HttpClient
. Note that this method should only be used outside of the context of a
Micronaut application. Within Micronaut use Inject
to inject a client instead.url
- The base URL