Package io.micronaut.http.client
Interface RawHttpClient
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Implementing Classes:
DefaultHttpClient
HTTP client that allows sending "raw" requests with a
ByteBody
for the request and
response body.- Since:
- 4.7.0
- Author:
- Jonas Konrad
-
Method Summary
Modifier and TypeMethodDescriptionstatic RawHttpClient
Create a newRawHttpClient
.static RawHttpClient
create
(@Nullable URI url, @NonNull HttpClientConfiguration configuration) Create a newRawHttpClient
with the specified configuration.@NonNull Publisher<? extends HttpResponse<?>>
exchange
(@NonNull HttpRequest<?> request, @Nullable CloseableByteBody requestBody, @Nullable Thread blockedThread) Send a raw request.
-
Method Details
-
exchange
@NonNull @SingleResult @NonNull Publisher<? extends HttpResponse<?>> exchange(@NonNull @NonNull HttpRequest<?> request, @Nullable @Nullable CloseableByteBody requestBody, @Nullable @Nullable Thread blockedThread) Send a raw request.- Parameters:
request
- The request metadata (method, URI, headers). Thebody
of this object is ignoredrequestBody
- The request body bytes.null
is equivalent to an empty body. The ownership of the body immediately transfers to the client, i.e. the client will always callCloseableByteBody.close()
on the body even if there is an error before the request is sent.blockedThread
- The thread that is blocked waiting for this request. This is used for deadlock detection. Optional parameter.- Returns:
- A mono that will contain the response to this request. This response will
usually be a
ByteBodyHttpResponse
, unless a filter replaced it.
-
create
Create a newRawHttpClient
. Note that this method should only be used outside the context of a Micronaut application. The returnedRawHttpClient
is not subject to dependency injection. The creator is responsible for closing the client to avoid leaking connections. Within a Micronaut application useInject
to inject a client instead.- Parameters:
url
- The base URL- Returns:
- The client
-
create
static RawHttpClient create(@Nullable @Nullable URI url, @NonNull @NonNull HttpClientConfiguration configuration) Create a newRawHttpClient
with the specified configuration. Note that this method should only be used outside the context of an application. Within Micronaut useInject
to inject a client instead- Parameters:
url
- The base URLconfiguration
- the client configuration- Returns:
- The client
-