Class DefaultHttpClient
- All Implemented Interfaces:
LifeCycle<HttpClient>
,HttpClient
,ProxyHttpClient
,RawHttpClient
,SseClient
,StreamingHttpClient
,WebSocketClient
,Closeable
,AutoCloseable
HttpClient
interface based on Netty.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Key used for connection pooling and determining host/port. -
Field Summary
Modifier and TypeFieldDescriptionprotected ByteBufferFactory<io.netty.buffer.ByteBufAllocator,
io.netty.buffer.ByteBuf> protected MediaTypeCodecRegistry
Fields inherited from interface io.micronaut.http.client.HttpClient
DEFAULT_ERROR_TYPE
Fields inherited from interface io.micronaut.websocket.WebSocketClient
SCHEME_WS, SCHEME_WSS
-
Constructor Summary
ConstructorDescriptionDeprecated.DefaultHttpClient
(@Nullable LoadBalancer loadBalancer, @NonNull HttpClientConfiguration configuration, @Nullable String contextPath, @Nullable ThreadFactory threadFactory, ClientSslBuilder nettyClientSslBuilder, @NonNull MediaTypeCodecRegistry codecRegistry, @NonNull MessageBodyHandlerRegistry handlerRegistry, @Nullable AnnotationMetadataResolver annotationMetadataResolver, ConversionService conversionService, HttpClientFilter... filters) Deprecated.Please go through thebuilder()
instead.DefaultHttpClient
(@Nullable LoadBalancer loadBalancer, @Nullable HttpVersionSelection explicitHttpVersion, @NonNull HttpClientConfiguration configuration, @Nullable String contextPath, @NonNull HttpClientFilterResolver<ClientFilterResolutionContext> filterResolver, @NonNull List<HttpFilterResolver.FilterEntry> clientFilterEntries, @Nullable ThreadFactory threadFactory, @NonNull ClientSslBuilder nettyClientSslBuilder, @NonNull MediaTypeCodecRegistry codecRegistry, @NonNull MessageBodyHandlerRegistry handlerRegistry, @NonNull WebSocketBeanRegistry webSocketBeanRegistry, @NonNull RequestBinderRegistry requestBinderRegistry, @Nullable io.netty.channel.EventLoopGroup eventLoopGroup, @NonNull io.netty.channel.ChannelFactory<? extends io.netty.channel.socket.SocketChannel> socketChannelFactory, @NonNull io.netty.channel.ChannelFactory<? extends io.netty.channel.socket.DatagramChannel> udpChannelFactory, NettyClientCustomizer clientCustomizer, @Nullable String informationalServiceId, ConversionService conversionService, @Nullable io.netty.resolver.AddressResolverGroup<?> resolverGroup) Deprecated.Please go through thebuilder()
instead.DefaultHttpClient
(@Nullable LoadBalancer loadBalancer, HttpClientConfiguration configuration) Deprecated.Please go through thebuilder()
instead.Deprecated.Please go through thebuilder()
instead.DefaultHttpClient
(@Nullable URI uri, @NonNull HttpClientConfiguration configuration) Deprecated.Please go through thebuilder()
instead.DefaultHttpClient
(@Nullable URI uri, @NonNull HttpClientConfiguration configuration, @NonNull ClientSslBuilder clientSslBuilder) Deprecated.Please go through thebuilder()
instead. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull DefaultHttpClientBuilder
builder()
Create a new builder for aDefaultHttpClient
.void
close()
Delegates toLifeCycle.stop()
.<T extends AutoCloseable>
Publisher<T>connect
(Class<T> clientEndpointType, MutableHttpRequest<?> request) Connect the given client endpoint type to the URI over WebSocket.<T extends AutoCloseable>
Publisher<T>Connect the given client endpoint type.Access to the connection manager, for micronaut-oracle-cloud.<I> Publisher<ByteBuffer<?>>
dataStream
(HttpRequest<I> request) Request a stream of data where each emitted item is aByteBuffer
instance.<I> Publisher<ByteBuffer<?>>
dataStream
(HttpRequest<I> request, @NonNull Argument<?> errorType) Request a stream of data where each emitted item is aByteBuffer
instance.<I> Publisher<Event<ByteBuffer<?>>>
eventStream
(HttpRequest<I> request) Perform an HTTP request and receive data as a stream of SSEEvent
objects as they become available without blocking.eventStream
(HttpRequest<I> request, @NonNull Argument<B> eventType) Perform an HTTP request and receive data as a stream of SSEEvent
objects as they become available without blocking.eventStream
(HttpRequest<I> request, @NonNull Argument<B> eventType, @NonNull Argument<?> errorType) Perform an HTTP request and receive data as a stream of SSEEvent
objects as they become available without blocking.Publisher<? extends HttpResponse<?>>
exchange
(HttpRequest<?> request, @Nullable CloseableByteBody requestBody, @Nullable Thread blockedThread) Send a raw request.<I,
O, E> Publisher<HttpResponse<O>> 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.<I> Publisher<HttpResponse<ByteBuffer<?>>>
exchangeStream
(HttpRequest<I> request) Requests a stream data where each emitted item is aByteBuffer
wrapped in theHttpResponse
object (which remains the same for each emitted item).<I> Publisher<HttpResponse<ByteBuffer<?>>>
exchangeStream
(HttpRequest<I> request, @NonNull Argument<?> errorType) Requests a stream data where each emitted item is aByteBuffer
wrapped in theHttpResponse
object (which remains the same for each emitted item).Get the handler registry for this client.protected Object
org.slf4j.Logger
getLog()
Deprecated.Use body handlers insteadboolean
jsonStream
(HttpRequest<I> request) Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.<I,
O> Publisher<O> jsonStream
(HttpRequest<I> request, @NonNull Argument<O> type) Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.<I,
O> Publisher<O> jsonStream
(HttpRequest<I> request, @NonNull Argument<O> type, @NonNull Argument<?> errorType) Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.<I,
O> Publisher<O> jsonStream
(HttpRequest<I> request, @NonNull Class<O> type) Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.proxy
(HttpRequest<?> request) Proxy the given request and emit the response.proxy
(HttpRequest<?> request, @NonNull ProxyRequestOptions options) Proxy the given request and emit the response.protected <I> reactor.core.publisher.Mono<URI>
resolveRedirectURI
(HttpRequest<?> parentRequest, HttpRequest<I> request) protected <I> reactor.core.publisher.Mono<URI>
resolveRequestURI
(HttpRequest<I> request) protected <I> reactor.core.publisher.Mono<URI>
resolveRequestURI
(HttpRequest<I> request, boolean includeContextPath) <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 returnedPublisher
and converting the response body to the specified type.final void
setHandlerRegistry
(@NonNull MessageBodyHandlerRegistry handlerRegistry) Deprecated, for removal: This API element is subject to removal in a future version.Use builder insteadvoid
setMediaTypeCodecRegistry
(MediaTypeCodecRegistry mediaTypeCodecRegistry) Deprecated, for removal: This API element is subject to removal in a future version.Use builder insteadstart()
Starts the lifecyle component.stop()
Stops the life cycle component.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.http.client.HttpClient
exchange, exchange, exchange, exchange, exchange, refresh, retrieve, retrieve, retrieve, retrieve
Methods inherited from interface io.micronaut.http.client.sse.SseClient
eventStream, eventStream, eventStream
Methods inherited from interface io.micronaut.websocket.WebSocketClient
connect, connect
-
Field Details
-
mediaTypeCodecRegistry
-
byteBufferFactory
protected ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf> byteBufferFactory
-
-
Constructor Details
-
DefaultHttpClient
@Deprecated public DefaultHttpClient(@Nullable @Nullable LoadBalancer loadBalancer, @NonNull @NonNull HttpClientConfiguration configuration, @Nullable @Nullable String contextPath, @Nullable @Nullable ThreadFactory threadFactory, ClientSslBuilder nettyClientSslBuilder, @NonNull @NonNull MediaTypeCodecRegistry codecRegistry, @NonNull @NonNull MessageBodyHandlerRegistry handlerRegistry, @Nullable @Nullable AnnotationMetadataResolver annotationMetadataResolver, ConversionService conversionService, HttpClientFilter... filters) Deprecated.Please go through thebuilder()
instead. If you need access to properties that are not public in the builder, make them public in core and document their usage.Construct a client for the given arguments.- Parameters:
loadBalancer
- TheLoadBalancer
to use for selecting serversconfiguration
- TheHttpClientConfiguration
objectcontextPath
- The base URI to prepend to request uristhreadFactory
- The thread factory to use for client threadsnettyClientSslBuilder
- The SSL buildercodecRegistry
- TheMediaTypeCodecRegistry
to use for encoding and decoding objectshandlerRegistry
- The handler registry for encoding and decodingannotationMetadataResolver
- The annotation metadata resolverconversionService
- The conversion servicefilters
- The filters to use
-
DefaultHttpClient
@Deprecated public DefaultHttpClient(@Nullable @Nullable LoadBalancer loadBalancer, @Nullable @Nullable HttpVersionSelection explicitHttpVersion, @NonNull @NonNull HttpClientConfiguration configuration, @Nullable @Nullable String contextPath, @NonNull @NonNull HttpClientFilterResolver<ClientFilterResolutionContext> filterResolver, @NonNull @NonNull List<HttpFilterResolver.FilterEntry> clientFilterEntries, @Nullable @Nullable ThreadFactory threadFactory, @NonNull @NonNull ClientSslBuilder nettyClientSslBuilder, @NonNull @NonNull MediaTypeCodecRegistry codecRegistry, @NonNull @NonNull MessageBodyHandlerRegistry handlerRegistry, @NonNull @NonNull WebSocketBeanRegistry webSocketBeanRegistry, @NonNull @NonNull RequestBinderRegistry requestBinderRegistry, @Nullable @Nullable io.netty.channel.EventLoopGroup eventLoopGroup, @NonNull @NonNull io.netty.channel.ChannelFactory<? extends io.netty.channel.socket.SocketChannel> socketChannelFactory, @NonNull @NonNull io.netty.channel.ChannelFactory<? extends io.netty.channel.socket.DatagramChannel> udpChannelFactory, NettyClientCustomizer clientCustomizer, @Nullable @Nullable String informationalServiceId, ConversionService conversionService, @Nullable @Nullable io.netty.resolver.AddressResolverGroup<?> resolverGroup) Deprecated.Please go through thebuilder()
instead. If you need access to properties that are not public in the builder, make them public in core and document their usage.Construct a client for the given arguments.- Parameters:
loadBalancer
- TheLoadBalancer
to use for selecting serversexplicitHttpVersion
- The HTTP version to use. Can be null and defaults toHttpVersion.HTTP_1_1
configuration
- TheHttpClientConfiguration
objectcontextPath
- The base URI to prepend to request urisfilterResolver
- The http client filter resolverclientFilterEntries
- The client filter entriesthreadFactory
- The thread factory to use for client threadsnettyClientSslBuilder
- The SSL buildercodecRegistry
- TheMediaTypeCodecRegistry
to use for encoding and decoding objectshandlerRegistry
- The handler registry for encoding and decodingwebSocketBeanRegistry
- The websocket bean registryrequestBinderRegistry
- The request binder registryeventLoopGroup
- The event loop group to usesocketChannelFactory
- The socket channel factoryudpChannelFactory
- The UDP channel factoryclientCustomizer
- The pipeline customizerinformationalServiceId
- Optional service ID that will be passed to exceptions created by this clientconversionService
- The conversion serviceresolverGroup
- Optional predefined resolver group
-
DefaultHttpClient
Deprecated.Please go through thebuilder()
instead.- Parameters:
uri
- The URL
-
DefaultHttpClient
Deprecated.Please go through thebuilder()
instead. -
DefaultHttpClient
@Deprecated public DefaultHttpClient(@Nullable @Nullable URI uri, @NonNull @NonNull HttpClientConfiguration configuration) Deprecated.Please go through thebuilder()
instead.- Parameters:
uri
- The URIconfiguration
- TheHttpClientConfiguration
object
-
DefaultHttpClient
@Deprecated public DefaultHttpClient(@Nullable @Nullable URI uri, @NonNull @NonNull HttpClientConfiguration configuration, @NonNull @NonNull ClientSslBuilder clientSslBuilder) Deprecated.Please go through thebuilder()
instead.Constructor used by micronaut-oracle-cloud.- Parameters:
uri
- The URIconfiguration
- TheHttpClientConfiguration
objectclientSslBuilder
- The SSL builder
-
DefaultHttpClient
@Deprecated public DefaultHttpClient(@Nullable @Nullable LoadBalancer loadBalancer, HttpClientConfiguration configuration) Deprecated.Please go through thebuilder()
instead. If you need access to properties that are not public in the builder, make them public in core and document their usage.- Parameters:
loadBalancer
- TheLoadBalancer
to use for selecting serversconfiguration
- TheHttpClientConfiguration
object
-
-
Method Details
-
builder
Create a new builder for aDefaultHttpClient
.- Returns:
- The builder
- Since:
- 4.7.0
-
getConfiguration
- Returns:
- The configuration used by this client
-
getLog
public org.slf4j.Logger getLog()- Returns:
- The client-specific logger name
-
connectionManager
Access to the connection manager, for micronaut-oracle-cloud.- Returns:
- The connection manager of this client
-
start
Description copied from interface:LifeCycle
Starts the lifecyle component.- Specified by:
start
in interfaceLifeCycle<HttpClient>
- Returns:
- This lifecycle component
-
isRunning
public boolean isRunning()- Specified by:
isRunning
in interfaceLifeCycle<HttpClient>
- Returns:
- Whether the component is running
-
stop
Description copied from interface:LifeCycle
Stops the life cycle component.- Specified by:
stop
in interfaceLifeCycle<HttpClient>
- Returns:
- This lifecycle component
-
getMediaTypeCodecRegistry
Deprecated.Use body handlers instead- Returns:
- The
MediaTypeCodecRegistry
used by this client
-
setMediaTypeCodecRegistry
@Deprecated(forRemoval=true) public void setMediaTypeCodecRegistry(MediaTypeCodecRegistry mediaTypeCodecRegistry) Deprecated, for removal: This API element is subject to removal in a future version.Use builder insteadSets theMediaTypeCodecRegistry
used by this client.- Parameters:
mediaTypeCodecRegistry
- The registry to use. Should not be null
-
getHandlerRegistry
Get the handler registry for this client.- Returns:
- The handler registry
-
setHandlerRegistry
@Deprecated(forRemoval=true) public final void setHandlerRegistry(@NonNull @NonNull MessageBodyHandlerRegistry handlerRegistry) Deprecated, for removal: This API element is subject to removal in a future version.Use builder insteadSet the handler registry for this client.- Parameters:
handlerRegistry
- The handler registry
-
toBlocking
- Specified by:
toBlocking
in interfaceHttpClient
- Returns:
- A blocking HTTP client suitable for testing and non-production scenarios.
-
eventStream
Description copied from interface:SseClient
Perform an HTTP request and receive data as a stream of SSE
Event
objects as they become available without blocking.The downstream
Subscriber
can regulate demand via the subscription- Specified by:
eventStream
in interfaceSseClient
- Type Parameters:
I
- The request body type- Parameters:
request
- TheHttpRequest
to execute- Returns:
- A
Publisher
that emits anEvent
with the data represented as aByteBuffer
-
eventStream
public <I,B> Publisher<Event<B>> eventStream(@NonNull HttpRequest<I> request, @NonNull @NonNull Argument<B> eventType) Description copied from interface:SseClient
Perform an HTTP request and receive data as a stream of SSE
Event
objects as they become available without blocking.The downstream
Subscriber
can regulate demand via the subscription- Specified by:
eventStream
in interfaceSseClient
- Type Parameters:
I
- The request body typeB
- The event body type- Parameters:
request
- TheHttpRequest
to executeeventType
- The event data type- Returns:
- A
Publisher
that emits anEvent
with the data represented by the eventType argument
-
eventStream
public <I,B> Publisher<Event<B>> eventStream(@NonNull HttpRequest<I> request, @NonNull @NonNull Argument<B> eventType, @NonNull @NonNull Argument<?> errorType) Description copied from interface:SseClient
Perform an HTTP request and receive data as a stream of SSE
Event
objects as they become available without blocking.The downstream
Subscriber
can regulate demand via the subscription- Specified by:
eventStream
in interfaceSseClient
- Type Parameters:
I
- The request body typeB
- The event body type- Parameters:
request
- TheHttpRequest
to executeeventType
- The event data typeerrorType
- The type that the response body should be coerced into if the server responds with an error- Returns:
- A
Publisher
that emits anEvent
with the data represented by the eventType argument
-
dataStream
Description copied from interface:StreamingHttpClient
Request a stream of data where each emitted item is aByteBuffer
instance.- Specified by:
dataStream
in interfaceStreamingHttpClient
- Type Parameters:
I
- The request body type- Parameters:
request
- The request- Returns:
- A
Publisher
that emits a stream ofByteBuffer
instances
-
dataStream
public <I> Publisher<ByteBuffer<?>> dataStream(@NonNull HttpRequest<I> request, @NonNull @NonNull Argument<?> errorType) Description copied from interface:StreamingHttpClient
Request a stream of data where each emitted item is aByteBuffer
instance.- Specified by:
dataStream
in interfaceStreamingHttpClient
- Type Parameters:
I
- The request body type- Parameters:
request
- The requesterrorType
- The type that the response body should be coerced into if the server responds with an error- Returns:
- A
Publisher
that emits a stream ofByteBuffer
instances
-
exchangeStream
Description copied from interface:StreamingHttpClient
Requests a stream data where each emitted item is aByteBuffer
wrapped in theHttpResponse
object (which remains the same for each emitted item).- Specified by:
exchangeStream
in interfaceStreamingHttpClient
- Type Parameters:
I
- The request body type- Parameters:
request
- TheHttpRequest
- Returns:
- A
Publisher
that emits a stream ofByteBuffer
instances wrapped by aHttpResponse
-
exchangeStream
public <I> Publisher<HttpResponse<ByteBuffer<?>>> exchangeStream(@NonNull HttpRequest<I> request, @NonNull @NonNull Argument<?> errorType) Description copied from interface:StreamingHttpClient
Requests a stream data where each emitted item is aByteBuffer
wrapped in theHttpResponse
object (which remains the same for each emitted item).- Specified by:
exchangeStream
in interfaceStreamingHttpClient
- Type Parameters:
I
- The request body type- Parameters:
request
- TheHttpRequest
errorType
- The type that the response body should be coerced into if the server responds with an error- Returns:
- A
Publisher
that emits a stream ofByteBuffer
instances wrapped by aHttpResponse
-
jsonStream
public <I,O> Publisher<O> jsonStream(@NonNull HttpRequest<I> request, @NonNull @NonNull Argument<O> type) Description copied from interface:StreamingHttpClient
Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.
The downstream
Subscriber
can regulate demand via the subscription. Incoming data is buffered.- Specified by:
jsonStream
in interfaceStreamingHttpClient
- Type Parameters:
I
- The request body typeO
- The response type- Parameters:
request
- TheHttpRequest
to executetype
- The type of object to convert the JSON into- Returns:
- A
Publisher
that emits the fullHttpResponse
object
-
jsonStream
public <I,O> Publisher<O> jsonStream(@NonNull HttpRequest<I> request, @NonNull @NonNull Argument<O> type, @NonNull @NonNull Argument<?> errorType) Description copied from interface:StreamingHttpClient
Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.
The downstream
Subscriber
can regulate demand via the subscription. Incoming data is buffered.- Specified by:
jsonStream
in interfaceStreamingHttpClient
- Type Parameters:
I
- The request body typeO
- The response type- Parameters:
request
- TheHttpRequest
to executetype
- The type of object to convert the JSON intoerrorType
- The type that the response body should be coerced into if the server responds with an error- Returns:
- A
Publisher
that emits the fullHttpResponse
object
-
jsonStream
Description copied from interface:StreamingHttpClient
Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.
The downstream
Subscriber
can regulate demand via the subscription- Specified by:
jsonStream
in interfaceStreamingHttpClient
- Type Parameters:
I
- The request body type- Parameters:
request
- TheHttpRequest
to execute- Returns:
- A
Publisher
that emits the fullHttpResponse
object
-
jsonStream
public <I,O> Publisher<O> jsonStream(@NonNull HttpRequest<I> request, @NonNull @NonNull Class<O> type) Description copied from interface:StreamingHttpClient
Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.
The downstream
Subscriber
can regulate demand via the subscription- Specified by:
jsonStream
in interfaceStreamingHttpClient
- Type Parameters:
I
- The request body typeO
- The response type- Parameters:
request
- TheHttpRequest
to executetype
- The type of object to convert the JSON into- Returns:
- A
Publisher
that emits the fullHttpResponse
object
-
exchange
public <I,O, Publisher<HttpResponse<O>> exchangeE> (@NonNull HttpRequest<I> request, @NonNull @NonNull Argument<O> bodyType, @NonNull @NonNull Argument<E> errorType) Description copied from interface:HttpClient
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 interfaceHttpClient
- 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:
- A
Publisher
that emits the fullHttpResponse
object
-
retrieve
public <I,O, Publisher<O> retrieveE> (HttpRequest<I> request, Argument<O> bodyType, Argument<E> errorType) Description copied from interface:HttpClient
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.- Specified by:
retrieve
in interfaceHttpClient
- 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:
- A
Publisher
that emits a result of the given type
-
connect
public <T extends AutoCloseable> Publisher<T> connect(Class<T> clientEndpointType, MutableHttpRequest<?> request) Description copied from interface:WebSocketClient
Connect the given client endpoint type to the URI over WebSocket.- Specified by:
connect
in interfaceWebSocketClient
- Type Parameters:
T
- The generic type- Parameters:
clientEndpointType
- The endpoint type. Should be a class annotated withClientWebSocket
request
- The original request to establish the connection- Returns:
- A
Publisher
that emits theClientWebSocket
instance
-
connect
public <T extends AutoCloseable> Publisher<T> connect(Class<T> clientEndpointType, Map<String, Object> parameters) Description copied from interface:WebSocketClient
Connect the given client endpoint type. UnlikeWebSocketClient.connect(Class, URI)
this method will the value declared within theClientWebSocket
as the URI and expand the URI with the given parameters.- Specified by:
connect
in interfaceWebSocketClient
- Type Parameters:
T
- The generic type- Parameters:
clientEndpointType
- The endpoint type. Should be a class annotated withClientWebSocket
parameters
- The URI parameters for the endpoint- Returns:
- A
Publisher
that emits theClientWebSocket
instance
-
close
public void close()Description copied from interface:LifeCycle
Delegates toLifeCycle.stop()
.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceLifeCycle<HttpClient>
- Specified by:
close
in interfaceWebSocketClient
-
proxy
Description copied from interface:ProxyHttpClient
Proxy the given request and emit the response. This method expects the full absolute URL to be included in the request. If a relative URL is specified then the method will try to resolve the URI for the current server otherwise an exception will be thrown.- Specified by:
proxy
in interfaceProxyHttpClient
- Parameters:
request
- The request- Returns:
- A publisher that emits the response.
-
proxy
public Publisher<MutableHttpResponse<?>> proxy(@NonNull HttpRequest<?> request, @NonNull @NonNull ProxyRequestOptions options) Description copied from interface:ProxyHttpClient
Proxy the given request and emit the response. This method expects the full absolute URL to be included in the request. If a relative URL is specified then the method will try to resolve the URI for the current server otherwise an exception will be thrown.- Specified by:
proxy
in interfaceProxyHttpClient
- Parameters:
request
- The requestoptions
- Further options for the proxy request- Returns:
- A publisher that emits the response.
-
resolveRequestURI
- Type Parameters:
I
- The input type- Parameters:
request
- The request- Returns:
- A
Publisher
with the resolved URI
-
resolveRequestURI
protected <I> reactor.core.publisher.Mono<URI> resolveRequestURI(HttpRequest<I> request, boolean includeContextPath) - Type Parameters:
I
- The input type- Parameters:
request
- The requestincludeContextPath
- Whether to prepend the client context path- Returns:
- A
Publisher
with the resolved URI
-
resolveRedirectURI
protected <I> reactor.core.publisher.Mono<URI> resolveRedirectURI(HttpRequest<?> parentRequest, HttpRequest<I> request) - Type Parameters:
I
- The input type- Parameters:
parentRequest
- The parent requestrequest
- The redirect location request- Returns:
- A
Publisher
with the resolved URI
-
getLoadBalancerDiscriminator
- Returns:
- The discriminator to use when selecting a server for the purposes of load balancing (defaults to null)
-
exchange
public Publisher<? extends HttpResponse<?>> exchange(HttpRequest<?> request, @Nullable @Nullable CloseableByteBody requestBody, @Nullable @Nullable Thread blockedThread) Description copied from interface:RawHttpClient
Send a raw request.- Specified by:
exchange
in interfaceRawHttpClient
- 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.
-
builder()
instead.