Package io.micronaut.http.client.jdk
Class JdkBlockingHttpClient
java.lang.Object
io.micronaut.http.client.jdk.JdkBlockingHttpClient
- All Implemented Interfaces:
BlockingHttpClient
,Closeable
,AutoCloseable
HttpClient
implementation for java.net.http.* HTTP Client.- Since:
- 4.0.0
- Author:
- Sergio del Amo
-
Field Summary
Modifier and TypeFieldDescriptionprotected final HttpClient
protected final String
protected final HttpClientConfiguration
protected final String
protected final ConversionService
protected final CookieDecoder
protected final CookieManager
static final String
static final String
protected final HttpVersionSelection
protected final LoadBalancer
protected final org.slf4j.Logger
protected MediaTypeCodecRegistry
protected final RequestBinderRegistry
protected final JdkClientSslBuilder
static final String
-
Constructor Summary
ConstructorDescriptionJdkBlockingHttpClient
(LoadBalancer loadBalancer, HttpVersionSelection httpVersion, HttpClientConfiguration configuration, String contextPath, MediaTypeCodecRegistry mediaTypeCodecRegistry, RequestBinderRegistry requestBinderRegistry, String clientId, ConversionService conversionService, JdkClientSslBuilder sslBuilder, CookieDecoder cookieDecoder) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
<I,
O, E> 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 returnedPublisher
and converting the response body to the specified type.protected <I> reactor.core.publisher.Mono<HttpRequest>
mapToHttpRequest
(HttpRequest<I> request, Argument<?> bodyType) Convert the Micronaut request to a JDK request.protected <O> @NonNull HttpResponse<O>
response
(HttpResponse<byte[]> netResponse, @NonNull Argument<O> bodyType) Convert the JDK response to a Micronaut response.void
setMediaTypeCodecRegistry
(MediaTypeCodecRegistry mediaTypeCodecRegistry)
-
Field Details
-
H2C_ERROR_MESSAGE
- See Also:
-
H3_ERROR_MESSAGE
- See Also:
-
WEIRD_ALPN_ERROR_MESSAGE
- See Also:
-
loadBalancer
-
httpVersion
-
configuration
-
contextPath
-
client
-
cookieManager
-
requestBinderRegistry
-
clientId
-
conversionService
-
sslBuilder
-
log
protected final org.slf4j.Logger log -
cookieDecoder
-
mediaTypeCodecRegistry
-
-
Constructor Details
-
JdkBlockingHttpClient
public JdkBlockingHttpClient(LoadBalancer loadBalancer, HttpVersionSelection httpVersion, HttpClientConfiguration configuration, String contextPath, MediaTypeCodecRegistry mediaTypeCodecRegistry, RequestBinderRegistry requestBinderRegistry, String clientId, ConversionService conversionService, JdkClientSslBuilder sslBuilder, CookieDecoder cookieDecoder)
-
-
Method Details
-
exchange
public <I,O, HttpResponse<O> exchangeE> (HttpRequest<I> request, Argument<O> bodyType, Argument<E> errorType) Description copied from interface:BlockingHttpClient
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 dataBy default the exchange
Content-Type
is application/json, unless otherwise specified in the passedHttpRequest
- Specified by:
exchange
in interfaceBlockingHttpClient
- Type Parameters:
I
- The request body typeO
- The response body typeE
- The error type- Parameters:
request
- TheHttpRequest
to executebodyType
- The body typeerrorType
- The error type- Returns:
- The full
HttpResponse
object
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
getMediaTypeCodecRegistry
- Returns:
- The
MediaTypeCodecRegistry
-
setMediaTypeCodecRegistry
- Parameters:
mediaTypeCodecRegistry
- TheMediaTypeCodecRegistry
-
mapToHttpRequest
protected <I> reactor.core.publisher.Mono<HttpRequest> mapToHttpRequest(HttpRequest<I> request, Argument<?> bodyType) Convert the Micronaut request to a JDK request.- Type Parameters:
I
- The body type- Parameters:
request
- The Micronaut request objectbodyType
- The body type- Returns:
- A JDK request object
-
response
@NonNull protected <O> @NonNull HttpResponse<O> response(@NonNull HttpResponse<byte[]> netResponse, @NonNull @NonNull Argument<O> bodyType) Convert the JDK response to a Micronaut response.- Type Parameters:
O
- The body type- Parameters:
netResponse
- The JDK responsebodyType
- The body type- Returns:
- A Micronaut response
-