@Internal public class DefaultHttpClient extends Object implements WebSocketClient, HttpClient, StreamingHttpClient, SseClient, ProxyHttpClient, Closeable, AutoCloseable
HttpClient interface based on Netty.| Modifier and Type | Class and Description |
|---|---|
protected class |
DefaultHttpClient.HttpClientInitializer
Initializes the HTTP client channel.
|
protected class |
DefaultHttpClient.NettyRequestWriter
A Netty request writer.
|
| Modifier and Type | Field and Description |
|---|---|
protected io.netty.bootstrap.Bootstrap |
bootstrap |
protected ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf> |
byteBufferFactory |
protected io.netty.channel.EventLoopGroup |
group |
protected MediaTypeCodecRegistry |
mediaTypeCodecRegistry |
SCHEME_WS, SCHEME_WSSDEFAULT_ERROR_TYPE| Constructor and Description |
|---|
DefaultHttpClient() |
DefaultHttpClient(LoadBalancer loadBalancer,
HttpClientConfiguration configuration,
List<InvocationInstrumenterFactory> invocationInstrumenterFactories) |
DefaultHttpClient(LoadBalancer loadBalancer,
HttpClientConfiguration configuration,
String contextPath,
ThreadFactory threadFactory,
NettyClientSslBuilder nettyClientSslBuilder,
MediaTypeCodecRegistry codecRegistry,
AnnotationMetadataResolver annotationMetadataResolver,
List<InvocationInstrumenterFactory> invocationInstrumenterFactories,
HttpClientFilter... filters)
Construct a client for the given arguments.
|
DefaultHttpClient(LoadBalancer loadBalancer,
HttpVersion httpVersion,
HttpClientConfiguration configuration,
String contextPath,
HttpClientFilterResolver<ClientFilterResolutionContext> filterResolver,
List<HttpFilterResolver.FilterEntry<HttpClientFilter>> clientFilterEntries,
ThreadFactory threadFactory,
NettyClientSslBuilder nettyClientSslBuilder,
MediaTypeCodecRegistry codecRegistry,
WebSocketBeanRegistry webSocketBeanRegistry,
RequestBinderRegistry requestBinderRegistry,
io.netty.channel.EventLoopGroup eventLoopGroup,
io.netty.channel.ChannelFactory socketChannelFactory,
Collection<ChannelPipelineListener> pipelineListeners,
List<InvocationInstrumenterFactory> invocationInstrumenterFactories)
Construct a client for the given arguments.
|
DefaultHttpClient(URI uri) |
DefaultHttpClient(URI uri,
HttpClientConfiguration configuration) |
| Modifier and Type | Method and Description |
|---|---|
protected <I,O> Publisher<HttpResponse<O>> |
applyFilterToResponsePublisher(HttpRequest<?> parentRequest,
HttpRequest<I> request,
URI requestURI,
AtomicReference<HttpRequest> requestWrapper,
Publisher<HttpResponse<O>> responsePublisher) |
protected <I> Function<URI,Publisher<ByteBuffer<?>>> |
buildDataStreamPublisher(HttpRequest<I> request)
Deprecated.
|
protected <I> Function<URI,Publisher<ByteBuffer<?>>> |
buildDataStreamPublisher(HttpRequest<I> request,
Argument<?> errorType) |
protected <I,O,E> Function<URI,Publisher<? extends HttpResponse<O>>> |
buildExchangePublisher(HttpRequest<?> parentRequest,
HttpRequest<I> request,
Argument<O> bodyType,
Argument<E> errorType) |
protected <I> Function<URI,Publisher<HttpResponse<ByteBuffer<?>>>> |
buildExchangeStreamPublisher(HttpRequest<I> request,
Argument<?> errorType) |
protected <I,O> Function<URI,Publisher<O>> |
buildJsonStreamPublisher(HttpRequest<?> parentRequest,
HttpRequest<I> request,
Argument<O> type,
Argument<?> errorType) |
protected DefaultHttpClient.NettyRequestWriter |
buildNettyRequest(MutableHttpRequest request,
URI requestURI,
MediaType requestContentType,
boolean permitsBody,
Argument<?> bodyType,
Consumer<? super Throwable> onError,
boolean closeChannelAfterWrite) |
protected io.netty.handler.ssl.SslContext |
buildSslContext(URI uriObject)
Builds an
SslContext for the given URI if necessary. |
protected <I> Publisher<HttpResponse<Object>> |
buildStreamExchange(HttpRequest<?> parentRequest,
HttpRequest<I> request,
URI requestURI)
Deprecated.
|
protected <I> Publisher<HttpResponse<Object>> |
buildStreamExchange(HttpRequest<?> parentRequest,
HttpRequest<I> request,
URI requestURI,
Argument<?> errorType) |
void |
close()
Delegates to
LifeCycle.stop(). |
protected void |
closeChannelAsync(io.netty.channel.Channel channel) |
protected void |
configureHttp2ClearText(DefaultHttpClient.HttpClientInitializer httpClientInitializer,
io.netty.channel.socket.SocketChannel ch,
io.netty.handler.codec.http2.HttpToHttp2ConnectionHandler connectionHandler)
Configures HTTP/2 handling for plaintext (non-SSL) connections.
|
protected void |
configureHttp2Ssl(DefaultHttpClient.HttpClientInitializer httpClientInitializer,
io.netty.channel.socket.SocketChannel ch,
io.netty.handler.ssl.SslContext sslCtx,
String host,
int port,
io.netty.handler.codec.http2.HttpToHttp2ConnectionHandler connectionHandler)
Configures HTTP/2 for the channel when SSL is enabled.
|
protected void |
configureProxy(io.netty.channel.ChannelPipeline pipeline,
Proxy.Type proxyType,
SocketAddress proxyAddress)
Configures the HTTP proxy for the pipeline.
|
protected void |
configureProxy(io.netty.channel.ChannelPipeline pipeline,
Proxy proxy)
Configures the HTTP proxy for the pipeline.
|
<T extends AutoCloseable> |
connect(Class<T> clientEndpointType,
Map<String,Object> parameters)
Connect the given client endpoint type.
|
<T extends AutoCloseable> |
connect(Class<T> clientEndpointType,
MutableHttpRequest<?> request)
Connect the given client endpoint type to the URI over WebSocket.
|
protected io.netty.channel.nio.NioEventLoopGroup |
createEventLoopGroup(HttpClientConfiguration configuration,
ThreadFactory threadFactory)
Creates the
NioEventLoopGroup for this client. |
<I> Publisher<ByteBuffer<?>> |
dataStream(HttpRequest<I> request)
Request a stream of data where each emitted item is a
ByteBuffer instance. |
<I> Publisher<ByteBuffer<?>> |
dataStream(HttpRequest<I> request,
Argument<?> errorType)
Request a stream of data where each emitted item is a
ByteBuffer instance. |
protected io.netty.channel.ChannelFuture |
doConnect(io.netty.bootstrap.Bootstrap bootstrap,
String host,
int port)
Creates an initial connection with the given bootstrap and remote host.
|
protected io.netty.channel.ChannelFuture |
doConnect(HttpRequest<?> request,
String host,
int port,
io.netty.handler.ssl.SslContext sslCtx,
boolean isStream,
boolean isProxy,
Consumer<io.netty.channel.ChannelHandlerContext> contextConsumer)
Creates an initial connection to the given remote host.
|
protected io.netty.channel.ChannelFuture |
doConnect(HttpRequest<?> request,
String host,
int port,
io.netty.handler.ssl.SslContext sslCtx,
boolean isStream,
Consumer<io.netty.channel.ChannelHandlerContext> contextConsumer)
Creates an initial connection to the given remote host.
|
protected io.netty.channel.ChannelFuture |
doConnect(HttpRequest<?> request,
URI uri,
io.netty.handler.ssl.SslContext sslCtx,
boolean isStream,
boolean isProxy,
Consumer<io.netty.channel.ChannelHandlerContext> contextConsumer)
Creates an initial connection to the given remote host.
|
protected io.netty.channel.ChannelFuture |
doConnect(HttpRequest<?> request,
URI uri,
io.netty.handler.ssl.SslContext sslCtx,
boolean isStream,
Consumer<io.netty.channel.ChannelHandlerContext> contextConsumer)
Creates an initial connection to the given remote host.
|
<I> Publisher<Event<ByteBuffer<?>>> |
eventStream(HttpRequest<I> request)
Perform an HTTP request and receive data as a stream of SSE
Event objects as they become available without blocking. |
<I,B> Publisher<Event<B>> |
eventStream(HttpRequest<I> request,
Argument<B> eventType)
Perform an HTTP request and receive data as a stream of SSE
Event objects as they become available without blocking. |
<I,B> Publisher<Event<B>> |
eventStream(HttpRequest<I> request,
Argument<B> eventType,
Argument<?> errorType)
Perform an HTTP request and receive data as a stream of SSE
Event objects as they become available without blocking. |
<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. |
<I> Publisher<HttpResponse<ByteBuffer<?>>> |
exchangeStream(HttpRequest<I> request)
Requests a stream data where each emitted item is a
ByteBuffer wrapped in the HttpResponse object
(which remains the same for each emitted item). |
<I> Publisher<HttpResponse<ByteBuffer<?>>> |
exchangeStream(HttpRequest<I> request,
Argument<?> errorType)
Requests a stream data where each emitted item is a
ByteBuffer wrapped in the HttpResponse object
(which remains the same for each emitted item). |
HttpClientConfiguration |
getConfiguration() |
protected Object |
getLoadBalancerDiscriminator() |
org.slf4j.Logger |
getLog() |
MediaTypeCodecRegistry |
getMediaTypeCodecRegistry() |
boolean |
isRunning() |
<I> Publisher<Map<String,Object>> |
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,
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,
Argument<O> type,
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,
Class<O> type)
Perform an HTTP request and receive data as a stream of JSON objects as they become available without blocking.
|
protected io.netty.handler.codec.http2.HttpToHttp2ConnectionHandlerBuilder |
newHttp2ConnectionHandlerBuilder(io.netty.handler.codec.http2.Http2Connection connection,
HttpClientConfiguration configuration,
boolean stream)
Creates a new
HttpToHttp2ConnectionHandlerBuilder for the given HTTP/2 connection object and config. |
protected URI |
prependContextPath(URI requestURI) |
Publisher<MutableHttpResponse<?>> |
proxy(HttpRequest<?> request)
Proxy the given request and emit the response.
|
protected <I> Publisher<URI> |
resolveRedirectURI(HttpRequest<?> parentRequest,
HttpRequest<I> request) |
protected <I> Publisher<URI> |
resolveRequestURI(HttpRequest<I> request) |
protected <I> Publisher<URI> |
resolveRequestURI(HttpRequest<I> request,
boolean includeContextPath) |
void |
setMediaTypeCodecRegistry(MediaTypeCodecRegistry mediaTypeCodecRegistry)
Sets the
MediaTypeCodecRegistry used by this client. |
HttpClient |
start()
Starts the lifecyle component.
|
HttpClient |
stop()
Stops the life cycle component.
|
BlockingHttpClient |
toBlocking() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconnect, connect, create, create, create, createcreate, createexchange, exchange, exchange, exchange, exchange, refresh, retrieve, retrieve, retrieve, retrieve, retrievecreate, create, eventStream, eventStream, eventStreamcreate, createprotected final io.netty.bootstrap.Bootstrap bootstrap
protected io.netty.channel.EventLoopGroup group
protected MediaTypeCodecRegistry mediaTypeCodecRegistry
protected ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf> byteBufferFactory
public DefaultHttpClient(@Nullable LoadBalancer loadBalancer, @NonNull HttpClientConfiguration configuration, @Nullable String contextPath, @Nullable ThreadFactory threadFactory, NettyClientSslBuilder nettyClientSslBuilder, MediaTypeCodecRegistry codecRegistry, @Nullable AnnotationMetadataResolver annotationMetadataResolver, List<InvocationInstrumenterFactory> invocationInstrumenterFactories, HttpClientFilter... filters)
loadBalancer - The LoadBalancer to use for selecting serversconfiguration - The HttpClientConfiguration objectcontextPath - The base URI to prepend to request uristhreadFactory - The thread factory to use for client threadsnettyClientSslBuilder - The SSL buildercodecRegistry - The MediaTypeCodecRegistry to use for encoding and decoding objectsannotationMetadataResolver - The annotation metadata resolverinvocationInstrumenterFactories - The invocation instrumeter factories to instrument netty handlers execution withfilters - The filters to usepublic DefaultHttpClient(@Nullable LoadBalancer loadBalancer, @Nullable HttpVersion httpVersion, @NonNull HttpClientConfiguration configuration, @Nullable String contextPath, @NonNull HttpClientFilterResolver<ClientFilterResolutionContext> filterResolver, List<HttpFilterResolver.FilterEntry<HttpClientFilter>> clientFilterEntries, @Nullable ThreadFactory threadFactory, @NonNull NettyClientSslBuilder nettyClientSslBuilder, @NonNull MediaTypeCodecRegistry codecRegistry, @NonNull WebSocketBeanRegistry webSocketBeanRegistry, @NonNull RequestBinderRegistry requestBinderRegistry, @Nullable io.netty.channel.EventLoopGroup eventLoopGroup, @NonNull io.netty.channel.ChannelFactory socketChannelFactory, Collection<ChannelPipelineListener> pipelineListeners, List<InvocationInstrumenterFactory> invocationInstrumenterFactories)
loadBalancer - The LoadBalancer to use for selecting servershttpVersion - The HTTP version to use. Can be null and defaults to HttpVersion.HTTP_1_1configuration - The HttpClientConfiguration 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 - The MediaTypeCodecRegistry to use for encoding and decoding objectswebSocketBeanRegistry - The websocket bean registryrequestBinderRegistry - The request binder registryeventLoopGroup - The event loop group to usesocketChannelFactory - The socket channel factorypipelineListeners - The listeners to call for pipeline customizationinvocationInstrumenterFactories - The invocation instrumeter factories to instrument netty handlers execution withpublic DefaultHttpClient()
public DefaultHttpClient(@Nullable URI uri, @NonNull HttpClientConfiguration configuration)
uri - The URIconfiguration - The HttpClientConfiguration objectpublic DefaultHttpClient(@Nullable LoadBalancer loadBalancer, HttpClientConfiguration configuration, List<InvocationInstrumenterFactory> invocationInstrumenterFactories)
loadBalancer - The LoadBalancer to use for selecting serversconfiguration - The HttpClientConfiguration objectinvocationInstrumenterFactories - The invocation instrumeter factories to instrument netty handlers execution withpublic HttpClientConfiguration getConfiguration()
public org.slf4j.Logger getLog()
public HttpClient start()
LifeCyclestart in interface LifeCycle<HttpClient>public boolean isRunning()
isRunning in interface LifeCycle<HttpClient>public HttpClient stop()
LifeCyclestop in interface LifeCycle<HttpClient>public MediaTypeCodecRegistry getMediaTypeCodecRegistry()
MediaTypeCodecRegistry used by this clientpublic void setMediaTypeCodecRegistry(MediaTypeCodecRegistry mediaTypeCodecRegistry)
MediaTypeCodecRegistry used by this client.mediaTypeCodecRegistry - The registry to use. Should not be nullpublic BlockingHttpClient toBlocking()
toBlocking in interface HttpClientpublic <I> Publisher<Event<ByteBuffer<?>>> eventStream(@NonNull HttpRequest<I> request)
SseClientPerform 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
eventStream in interface SseClientI - The request body typerequest - The HttpRequest to executePublisher that emits an Event with the data represented as a ByteBufferpublic <I,B> Publisher<Event<B>> eventStream(@NonNull HttpRequest<I> request, @NonNull Argument<B> eventType)
SseClientPerform 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
eventStream in interface SseClientI - The request body typeB - The event body typerequest - The HttpRequest to executeeventType - The event data typePublisher that emits an Event with the data represented by the eventType argumentpublic <I,B> Publisher<Event<B>> eventStream(@NonNull HttpRequest<I> request, @NonNull Argument<B> eventType, @NonNull Argument<?> errorType)
SseClientPerform 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
eventStream in interface SseClientI - The request body typeB - The event body typerequest - The HttpRequest to executeeventType - The event data typeerrorType - The type that the response body should be coerced into if the server responds with an errorPublisher that emits an Event with the data represented by the eventType argumentpublic <I> Publisher<ByteBuffer<?>> dataStream(@NonNull HttpRequest<I> request)
StreamingHttpClientByteBuffer instance.dataStream in interface StreamingHttpClientI - The request body typerequest - The requestPublisher that emits a stream of ByteBuffer instancespublic <I> Publisher<ByteBuffer<?>> dataStream(@NonNull HttpRequest<I> request, @NonNull Argument<?> errorType)
StreamingHttpClientByteBuffer instance.dataStream in interface StreamingHttpClientI - The request body typerequest - The requesterrorType - The type that the response body should be coerced into if the server responds with an errorPublisher that emits a stream of ByteBuffer instancespublic <I> Publisher<HttpResponse<ByteBuffer<?>>> exchangeStream(@NonNull HttpRequest<I> request)
StreamingHttpClientByteBuffer wrapped in the HttpResponse object
(which remains the same for each emitted item).exchangeStream in interface StreamingHttpClientI - The request body typerequest - The HttpRequestPublisher that emits a stream of ByteBuffer instances wrapped by a HttpResponsepublic <I> Publisher<HttpResponse<ByteBuffer<?>>> exchangeStream(@NonNull HttpRequest<I> request, @NonNull Argument<?> errorType)
StreamingHttpClientByteBuffer wrapped in the HttpResponse object
(which remains the same for each emitted item).exchangeStream in interface StreamingHttpClientI - The request body typerequest - The HttpRequesterrorType - The type that the response body should be coerced into if the server responds with an errorPublisher that emits a stream of ByteBuffer instances wrapped by a HttpResponsepublic <I,O> Publisher<O> jsonStream(@NonNull HttpRequest<I> request, @NonNull Argument<O> type)
StreamingHttpClientPerform 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.
jsonStream in interface StreamingHttpClientI - The request body typeO - The response typerequest - The HttpRequest to executetype - The type of object to convert the JSON intoPublisher that emits the full HttpResponse objectpublic <I,O> Publisher<O> jsonStream(@NonNull HttpRequest<I> request, @NonNull Argument<O> type, @NonNull Argument<?> errorType)
StreamingHttpClientPerform 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.
jsonStream in interface StreamingHttpClientI - The request body typeO - The response typerequest - The HttpRequest 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 errorPublisher that emits the full HttpResponse objectpublic <I> Publisher<Map<String,Object>> jsonStream(@NonNull HttpRequest<I> request)
StreamingHttpClientPerform 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
jsonStream in interface StreamingHttpClientI - The request body typerequest - The HttpRequest to executePublisher that emits the full HttpResponse objectpublic <I,O> Publisher<O> jsonStream(@NonNull HttpRequest<I> request, @NonNull Class<O> type)
StreamingHttpClientPerform 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
jsonStream in interface StreamingHttpClientI - The request body typeO - The response typerequest - The HttpRequest to executetype - The type of object to convert the JSON intoPublisher that emits the full HttpResponse objectpublic <I,O,E> Publisher<HttpResponse<O>> exchange(@NonNull HttpRequest<I> request, @NonNull Argument<O> bodyType, @NonNull Argument<E> errorType)
HttpClientPerform 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
exchange in interface HttpClientI - 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 objectpublic <T extends AutoCloseable> Publisher<T> connect(Class<T> clientEndpointType, MutableHttpRequest<?> request)
WebSocketClientconnect in interface WebSocketClientT - The generic typeclientEndpointType - The endpoint type. Should be a class annotated with ClientWebSocketrequest - The original request to establish the connectionPublisher that emits the ClientWebSocket instancepublic <T extends AutoCloseable> Publisher<T> connect(Class<T> clientEndpointType, Map<String,Object> parameters)
WebSocketClientWebSocketClient.connect(Class, URI) this method will the value declared within the ClientWebSocket as the URI
and expand the URI with the given parameters.connect in interface WebSocketClientT - The generic typeclientEndpointType - The endpoint type. Should be a class annotated with ClientWebSocketparameters - The URI parameters for the endpointPublisher that emits the ClientWebSocket instancepublic void close()
LifeCycleLifeCycle.stop().close in interface LifeCycle<HttpClient>close in interface WebSocketClientclose in interface Closeableclose in interface AutoCloseableprotected <I> Function<URI,Publisher<HttpResponse<ByteBuffer<?>>>> buildExchangeStreamPublisher(@NonNull HttpRequest<I> request, @NonNull Argument<?> errorType)
I - The input typerequest - The requesterrorType - The error typeFunctionprotected <I,O> Function<URI,Publisher<O>> buildJsonStreamPublisher(HttpRequest<?> parentRequest, HttpRequest<I> request, Argument<O> type, Argument<?> errorType)
I - The input typeO - The output typeparentRequest - The parent requestrequest - The requesttype - The typeerrorType - The error typeFunction@Deprecated protected <I> Function<URI,Publisher<ByteBuffer<?>>> buildDataStreamPublisher(HttpRequest<I> request)
buildDataStreamPublisher(io.micronaut.http.HttpRequest, Argument) insteadI - The input typerequest - The requestFunctionprotected <I> Function<URI,Publisher<ByteBuffer<?>>> buildDataStreamPublisher(@NonNull HttpRequest<I> request, @NonNull Argument<?> errorType)
I - The input typerequest - The requesterrorType - The error typeFunction@Deprecated protected <I> Publisher<HttpResponse<Object>> buildStreamExchange(@Nullable HttpRequest<?> parentRequest, HttpRequest<I> request, URI requestURI)
buildStreamExchange(io.micronaut.http.HttpRequest, io.micronaut.http.HttpRequest, URI, Argument) instead.I - The input typeparentRequest - The parent requestrequest - The requestrequestURI - The request URIFluxprotected <I> Publisher<HttpResponse<Object>> buildStreamExchange(@Nullable HttpRequest<?> parentRequest, @NonNull HttpRequest<I> request, @NonNull URI requestURI, @NonNull Argument<?> errorType)
I - The input typeparentRequest - The parent requestrequest - The requestrequestURI - The request URIerrorType - The error typeFluxprotected <I,O,E> Function<URI,Publisher<? extends HttpResponse<O>>> buildExchangePublisher(HttpRequest<?> parentRequest, HttpRequest<I> request, @NonNull Argument<O> bodyType, @NonNull Argument<E> errorType)
I - The input typeO - The output typeE - The error typeparentRequest - The parent requestrequest - The requestbodyType - The body typeerrorType - The error typeFunctionprotected void closeChannelAsync(io.netty.channel.Channel channel)
channel - The channel to close asynchronouslyprotected <I> Publisher<URI> resolveRequestURI(HttpRequest<I> request)
I - The input typerequest - The requestPublisher with the resolved URIprotected <I> Publisher<URI> resolveRequestURI(HttpRequest<I> request, boolean includeContextPath)
I - The input typerequest - The requestincludeContextPath - Whether to prepend the client context pathPublisher with the resolved URIprotected <I> Publisher<URI> resolveRedirectURI(HttpRequest<?> parentRequest, HttpRequest<I> request)
I - The input typeparentRequest - The parent requestrequest - The redirect location requestPublisher with the resolved URIprotected URI prependContextPath(URI requestURI)
requestURI - The request URIprotected Object getLoadBalancerDiscriminator()
protected io.netty.channel.ChannelFuture doConnect(HttpRequest<?> request, URI uri, @Nullable io.netty.handler.ssl.SslContext sslCtx, boolean isStream, Consumer<io.netty.channel.ChannelHandlerContext> contextConsumer) throws HttpClientException
request - The requesturi - The URI to connect tosslCtx - The SslContext instanceisStream - Is the connection a stream connectioncontextConsumer - The logic to run once the channel is configured correctlyHttpClientException - If the URI is invalidprotected io.netty.channel.ChannelFuture doConnect(HttpRequest<?> request, URI uri, @Nullable io.netty.handler.ssl.SslContext sslCtx, boolean isStream, boolean isProxy, Consumer<io.netty.channel.ChannelHandlerContext> contextConsumer) throws HttpClientException
request - The requesturi - The URI to connect tosslCtx - The SslContext instanceisStream - Is the connection a stream connectionisProxy - Is this a streaming proxycontextConsumer - The logic to run once the channel is configured correctlyHttpClientException - If the URI is invalidprotected io.netty.channel.ChannelFuture doConnect(HttpRequest<?> request, String host, int port, @Nullable io.netty.handler.ssl.SslContext sslCtx, boolean isStream, Consumer<io.netty.channel.ChannelHandlerContext> contextConsumer)
request - The requesthost - The hostport - The portsslCtx - The SslContext instanceisStream - Is the connection a stream connectioncontextConsumer - The logic to run once the channel is configured correctlyprotected io.netty.channel.ChannelFuture doConnect(HttpRequest<?> request, String host, int port, @Nullable io.netty.handler.ssl.SslContext sslCtx, boolean isStream, boolean isProxy, Consumer<io.netty.channel.ChannelHandlerContext> contextConsumer)
request - The requesthost - The hostport - The portsslCtx - The SslContext instanceisStream - Is the connection a stream connectionisProxy - Is this a streaming proxycontextConsumer - The logic to run once the channel is configured correctlyprotected io.netty.channel.nio.NioEventLoopGroup createEventLoopGroup(HttpClientConfiguration configuration, ThreadFactory threadFactory)
NioEventLoopGroup for this client.configuration - The configurationthreadFactory - The thread factoryprotected io.netty.channel.ChannelFuture doConnect(io.netty.bootstrap.Bootstrap bootstrap,
String host,
int port)
bootstrap - The bootstrap instancehost - The hostport - The portprotected io.netty.handler.ssl.SslContext buildSslContext(URI uriObject)
SslContext for the given URI if necessary.uriObject - The URISslContext instanceprotected void configureProxy(io.netty.channel.ChannelPipeline pipeline,
Proxy proxy)
pipeline - The pipelineproxy - The proxyprotected void configureProxy(io.netty.channel.ChannelPipeline pipeline,
Proxy.Type proxyType,
SocketAddress proxyAddress)
pipeline - The pipelineproxyType - The proxy typeproxyAddress - The proxy addressprotected <I,O> Publisher<HttpResponse<O>> applyFilterToResponsePublisher(HttpRequest<?> parentRequest, HttpRequest<I> request, URI requestURI, AtomicReference<HttpRequest> requestWrapper, Publisher<HttpResponse<O>> responsePublisher)
I - The input typeO - The output typeparentRequest - The parent requestrequest - The requestrequestURI - The URI of the requestrequestWrapper - The request wrapperresponsePublisher - The response publisherPublisher for the responseprotected DefaultHttpClient.NettyRequestWriter buildNettyRequest(MutableHttpRequest request, URI requestURI, MediaType requestContentType, boolean permitsBody, @Nullable Argument<?> bodyType, Consumer<? super Throwable> onError, boolean closeChannelAfterWrite) throws io.netty.handler.codec.http.multipart.HttpPostRequestEncoder.ErrorDataEncoderException
request - The requestrequestURI - The URI of the requestrequestContentType - The request content typepermitsBody - Whether permits bodybodyType - The body typeonError - Called when the body publisher encounters an errorcloseChannelAfterWrite - Whether to close the channel. For stream requests we don't close the channel until disposed of.DefaultHttpClient.NettyRequestWriterHttpPostRequestEncoder.ErrorDataEncoderException - if there is an encoder exceptionprotected void configureHttp2Ssl(DefaultHttpClient.HttpClientInitializer httpClientInitializer, @NonNull io.netty.channel.socket.SocketChannel ch, @NonNull io.netty.handler.ssl.SslContext sslCtx, String host, int port, io.netty.handler.codec.http2.HttpToHttp2ConnectionHandler connectionHandler)
httpClientInitializer - The client initializerch - The channelsslCtx - The SSL contexthost - The hostport - The portconnectionHandler - The connection handlerprotected void configureHttp2ClearText(DefaultHttpClient.HttpClientInitializer httpClientInitializer, @NonNull io.netty.channel.socket.SocketChannel ch, @NonNull io.netty.handler.codec.http2.HttpToHttp2ConnectionHandler connectionHandler)
httpClientInitializer - The client initializerch - The channelconnectionHandler - The connection handler@NonNull protected io.netty.handler.codec.http2.HttpToHttp2ConnectionHandlerBuilder newHttp2ConnectionHandlerBuilder(@NonNull io.netty.handler.codec.http2.Http2Connection connection, @NonNull HttpClientConfiguration configuration, boolean stream)
HttpToHttp2ConnectionHandlerBuilder for the given HTTP/2 connection object and config.connection - The connectionconfiguration - The configurationstream - Whether this is a stream requestHttpToHttp2ConnectionHandlerBuilderpublic Publisher<MutableHttpResponse<?>> proxy(@NonNull HttpRequest<?> request)
ProxyHttpClientproxy in interface ProxyHttpClientrequest - The request