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 List<HttpFilterResolver.FilterEntry>
protected final String
protected final HttpClientConfiguration
protected final String
protected final ConversionService
protected final CookieDecoder
protected final CookieManager
protected final HttpClientFilterResolver<ClientFilterResolutionContext>
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, @Nullable HttpClientFilterResolver<ClientFilterResolutionContext> filterResolver, @Nullable List<HttpFilterResolver.FilterEntry> clientFilterEntries, MediaTypeCodecRegistry mediaTypeCodecRegistry, RequestBinderRegistry requestBinderRegistry, String clientId, ConversionService conversionService, JdkClientSslBuilder sslBuilder, CookieDecoder cookieDecoder) -
Method Summary
Modifier and TypeMethodDescriptionprotected <I,
R extends HttpResponse<?>>
Publisher<R>applyFilterToResponsePublisher
(HttpRequest<I> request, URI requestURI, Publisher<R> responsePublisher) void
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,
O> reactor.core.publisher.Flux<HttpResponse<O>> exchangeImpl
(HttpRequest<I> request, @NonNull Argument<O> bodyType) protected <I> reactor.core.publisher.Mono<HttpRequest>
mapToHttpRequest
(HttpRequest<I> request, Argument<?> bodyType) Convert the Micronaut request to a JDK request.protected reactor.core.publisher.Mono<URI>
resolveRequestUri
(HttpRequest<?> request) protected <O> @NonNull HttpResponse<O>
response
(HttpResponse<byte[]> netResponse, @NonNull Argument<O> bodyType) Convert the JDK response to a Micronaut response.protected <O> Publisher<HttpResponse<O>>
responsePublisher
(HttpRequest<?> request, Argument<O> bodyType) 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 -
filterResolver
-
clientFilterEntries
-
cookieDecoder
-
mediaTypeCodecRegistry
-
-
Constructor Details
-
JdkBlockingHttpClient
public JdkBlockingHttpClient(LoadBalancer loadBalancer, HttpVersionSelection httpVersion, HttpClientConfiguration configuration, String contextPath, @Nullable @Nullable HttpClientFilterResolver<ClientFilterResolutionContext> filterResolver, @Nullable @Nullable List<HttpFilterResolver.FilterEntry> clientFilterEntries, 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
-
resolveRequestUri
-
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
-
exchangeImpl
protected <I,O> reactor.core.publisher.Flux<HttpResponse<O>> exchangeImpl(@NonNull HttpRequest<I> request, @NonNull @NonNull Argument<O> bodyType) -
applyFilterToResponsePublisher
protected <I,R extends HttpResponse<?>> Publisher<R> applyFilterToResponsePublisher(HttpRequest<I> request, URI requestURI, Publisher<R> responsePublisher) -
responsePublisher
protected <O> Publisher<HttpResponse<O>> responsePublisher(HttpRequest<?> request, Argument<O> bodyType)
-