@Internal public class DefaultHttpClient extends java.lang.Object implements RxWebSocketClient, RxHttpClient, RxStreamingHttpClient, RxSseClient, RxProxyHttpClient, ChannelPipelineCustomizer, java.io.Closeable, java.lang.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_TYPEHANDLER_ACCESS_LOGGER, HANDLER_CONNECT_TTL, HANDLER_FLOW_CONTROL, HANDLER_HTTP_AGGREGATOR, HANDLER_HTTP_CHUNK, HANDLER_HTTP_CLIENT_CODEC, HANDLER_HTTP_CLIENT_INIT, HANDLER_HTTP_COMPRESSOR, HANDLER_HTTP_DECODER, HANDLER_HTTP_DECOMPRESSOR, HANDLER_HTTP_KEEP_ALIVE, HANDLER_HTTP_PROXY, HANDLER_HTTP_SERVER_CODEC, HANDLER_HTTP_STREAM, HANDLER_HTTP2_CONNECTION, HANDLER_HTTP2_PROTOCOL_NEGOTIATOR, HANDLER_HTTP2_SETTINGS, HANDLER_HTTP2_UPGRADE_REQUEST, HANDLER_IDLE_STATE, HANDLER_MICRONAUT_FULL_HTTP_RESPONSE, HANDLER_MICRONAUT_HTTP_RESPONSE_FULL, HANDLER_MICRONAUT_HTTP_RESPONSE_STREAM, HANDLER_MICRONAUT_INBOUND, HANDLER_MICRONAUT_SSE_CONTENT, HANDLER_MICRONAUT_SSE_EVENT_STREAM, HANDLER_MICRONAUT_WEBSOCKET_CLIENT, HANDLER_READ_TIMEOUT, HANDLER_SOCKS_5_PROXY, HANDLER_SSL, HANDLER_WEBSOCKET_UPGRADE| Constructor and Description |
|---|
DefaultHttpClient() |
DefaultHttpClient(LoadBalancer loadBalancer,
HttpClientConfiguration configuration) |
DefaultHttpClient(LoadBalancer loadBalancer,
HttpClientConfiguration configuration,
java.lang.String contextPath,
java.util.concurrent.ThreadFactory threadFactory,
NettyClientSslBuilder nettyClientSslBuilder,
MediaTypeCodecRegistry codecRegistry,
AnnotationMetadataResolver annotationMetadataResolver,
HttpClientFilter... filters)
Construct a client for the given arguments.
|
DefaultHttpClient(LoadBalancer loadBalancer,
HttpVersion httpVersion,
HttpClientConfiguration configuration,
java.lang.String contextPath,
HttpClientFilterResolver<ClientFilterResolutionContext> filterResolver,
java.util.List<HttpFilterResolver.FilterEntry<HttpClientFilter>> clientFilterEntries,
java.util.concurrent.ThreadFactory threadFactory,
NettyClientSslBuilder nettyClientSslBuilder,
MediaTypeCodecRegistry codecRegistry,
WebSocketBeanRegistry webSocketBeanRegistry,
RequestBinderRegistry requestBinderRegistry,
io.netty.channel.EventLoopGroup eventLoopGroup,
java.lang.Class<? extends io.netty.channel.socket.SocketChannel> socketChannelClass)
Construct a client for the given arguments.
|
DefaultHttpClient(java.net.URL url) |
DefaultHttpClient(java.net.URL url,
HttpClientConfiguration configuration) |
| Modifier and Type | Method and Description |
|---|---|
protected <I,O> org.reactivestreams.Publisher<HttpResponse<O>> |
applyFilterToResponsePublisher(HttpRequest<?> parentRequest,
HttpRequest<I> request,
java.net.URI requestURI,
java.util.concurrent.atomic.AtomicReference<HttpRequest> requestWrapper,
org.reactivestreams.Publisher<HttpResponse<O>> responsePublisher) |
protected <I> io.reactivex.functions.Function<java.net.URI,io.reactivex.Flowable<ByteBuffer<?>>> |
buildDataStreamPublisher(HttpRequest<I> request) |
protected <I,O,E> io.reactivex.functions.Function<java.net.URI,org.reactivestreams.Publisher<? extends HttpResponse<O>>> |
buildExchangePublisher(HttpRequest<?> parentRequest,
HttpRequest<I> request,
Argument<O> bodyType,
Argument<E> errorType) |
protected <I> io.reactivex.functions.Function<java.net.URI,io.reactivex.Flowable<HttpResponse<ByteBuffer<?>>>> |
buildExchangeStreamPublisher(HttpRequest<I> request) |
protected <I,O> io.reactivex.functions.Function<java.net.URI,io.reactivex.Flowable<O>> |
buildJsonStreamPublisher(HttpRequest<?> parentRequest,
HttpRequest<I> request,
Argument<O> type) |
protected DefaultHttpClient.NettyRequestWriter |
buildNettyRequest(MutableHttpRequest request,
java.net.URI requestURI,
MediaType requestContentType,
boolean permitsBody,
io.reactivex.functions.Consumer<? super java.lang.Throwable> onError,
boolean closeChannelAfterWrite) |
protected io.netty.handler.ssl.SslContext |
buildSslContext(java.net.URI uriObject)
Builds an
SslContext for the given URI if necessary. |
protected <I> io.reactivex.Flowable<HttpResponse<java.lang.Object>> |
buildStreamExchange(HttpRequest<?> parentRequest,
HttpRequest<I> request,
java.net.URI requestURI) |
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,
java.lang.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,
java.net.Proxy.Type proxyType,
java.net.SocketAddress proxyAddress)
Configures the HTTP proxy for the pipeline.
|
protected void |
configureProxy(io.netty.channel.ChannelPipeline pipeline,
java.net.Proxy proxy)
Configures the HTTP proxy for the pipeline.
|
<T extends java.lang.AutoCloseable> |
connect(java.lang.Class<T> clientEndpointType,
java.util.Map<java.lang.String,java.lang.Object> parameters)
Connect the given client endpoint type.
|
<T extends java.lang.AutoCloseable> |
connect(java.lang.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,
java.util.concurrent.ThreadFactory threadFactory)
Creates the
NioEventLoopGroup for this client. |
<I> io.reactivex.Flowable<ByteBuffer<?>> |
dataStream(HttpRequest<I> request)
Request a stream of data where each emitted item is a
ByteBuffer instance. |
protected io.netty.channel.ChannelFuture |
doConnect(io.netty.bootstrap.Bootstrap bootstrap,
java.lang.String host,
int port)
Creates an initial connection with the given bootstrap and remote host.
|
protected io.netty.channel.ChannelFuture |
doConnect(HttpRequest<?> request,
java.lang.String host,
int port,
io.netty.handler.ssl.SslContext sslCtx,
boolean isStream,
java.util.function.Consumer<io.netty.channel.ChannelHandlerContext> contextConsumer)
Creates an initial connection to the given remote host.
|
protected io.netty.channel.ChannelFuture |
doConnect(HttpRequest<?> request,
java.net.URI uri,
io.netty.handler.ssl.SslContext sslCtx,
boolean isStream,
java.util.function.Consumer<io.netty.channel.ChannelHandlerContext> contextConsumer)
Creates an initial connection to the given remote host.
|
void |
doOnConnect(ChannelPipelineListener listener)
A hook to customize the pipeline upon establishing a connection.
|
<I> io.reactivex.Flowable<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> io.reactivex.Flowable<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,O,E> io.reactivex.Flowable<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> io.reactivex.Flowable<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). |
HttpClientConfiguration |
getConfiguration() |
protected java.lang.Object |
getLoadBalancerDiscriminator() |
org.slf4j.Logger |
getLog() |
MediaTypeCodecRegistry |
getMediaTypeCodecRegistry() |
boolean |
isClientChannel() |
boolean |
isRunning() |
<I> io.reactivex.Flowable<java.util.Map<java.lang.String,java.lang.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> io.reactivex.Flowable<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> io.reactivex.Flowable<O> |
jsonStream(HttpRequest<I> request,
java.lang.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 java.net.URI |
prependContextPath(java.net.URI requestURI) |
io.reactivex.Flowable<MutableHttpResponse<?>> |
proxy(HttpRequest<?> request)
Proxy the given request and emit the response.
|
protected <I> org.reactivestreams.Publisher<java.net.URI> |
resolveRedirectURI(HttpRequest<?> parentRequest,
HttpRequest<I> request) |
protected <I> org.reactivestreams.Publisher<java.net.URI> |
resolveRequestURI(HttpRequest<I> request) |
protected <I> org.reactivestreams.Publisher<java.net.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, connectcreate, createexchange, exchange, exchange, exchange, exchange, retrieve, retrieve, retrieve, retrieve, retrieverefresheventStream, eventStream, eventStreamisServerChannelprotected 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,
HttpClientConfiguration configuration,
@Nullable
java.lang.String contextPath,
@Nullable
java.util.concurrent.ThreadFactory threadFactory,
NettyClientSslBuilder nettyClientSslBuilder,
MediaTypeCodecRegistry codecRegistry,
@Nullable
AnnotationMetadataResolver annotationMetadataResolver,
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 resolverfilters - The filters to usepublic DefaultHttpClient(@Nullable
LoadBalancer loadBalancer,
@Nullable
HttpVersion httpVersion,
@NonNull
HttpClientConfiguration configuration,
@Nullable
java.lang.String contextPath,
@NonNull
HttpClientFilterResolver<ClientFilterResolutionContext> filterResolver,
java.util.List<HttpFilterResolver.FilterEntry<HttpClientFilter>> clientFilterEntries,
@Nullable
java.util.concurrent.ThreadFactory threadFactory,
@NonNull
NettyClientSslBuilder nettyClientSslBuilder,
@NonNull
MediaTypeCodecRegistry codecRegistry,
@NonNull
WebSocketBeanRegistry webSocketBeanRegistry,
@NonNull
RequestBinderRegistry requestBinderRegistry,
@Nullable
io.netty.channel.EventLoopGroup eventLoopGroup,
@NonNull
java.lang.Class<? extends io.netty.channel.socket.SocketChannel> socketChannelClass)
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 usesocketChannelClass - The socket channel classpublic DefaultHttpClient(java.net.URL url)
url - The URLpublic DefaultHttpClient()
public DefaultHttpClient(java.net.URL url,
HttpClientConfiguration configuration)
url - The URLconfiguration - The HttpClientConfiguration objectpublic DefaultHttpClient(@Nullable
LoadBalancer loadBalancer,
HttpClientConfiguration configuration)
loadBalancer - The LoadBalancer to use for selecting serversconfiguration - The HttpClientConfiguration objectpublic 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> io.reactivex.Flowable<Event<ByteBuffer<?>>> eventStream(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 RxSseClienteventStream in interface SseClientI - The request body typerequest - The HttpRequest to executePublisher that emits an Event with the data represented as a ByteBufferpublic <I,B> io.reactivex.Flowable<Event<B>> eventStream(HttpRequest<I> request, 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 RxSseClienteventStream 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> io.reactivex.Flowable<ByteBuffer<?>> dataStream(HttpRequest<I> request)
StreamingHttpClientByteBuffer instance.dataStream in interface RxStreamingHttpClientdataStream in interface StreamingHttpClientI - The request body typerequest - The requestPublisher that emits a stream of ByteBuffer instancespublic <I> io.reactivex.Flowable<HttpResponse<ByteBuffer<?>>> exchangeStream(HttpRequest<I> request)
StreamingHttpClientByteBuffer wrapped in the HttpResponse object
(which remains the same for each emitted item).exchangeStream in interface RxStreamingHttpClientexchangeStream in interface StreamingHttpClientI - The request body typerequest - The HttpRequestPublisher that emits a stream of ByteBuffer instances wrapped by a HttpResponsepublic <I,O> io.reactivex.Flowable<O> jsonStream(HttpRequest<I> request, 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 RxStreamingHttpClientjsonStream 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> io.reactivex.Flowable<java.util.Map<java.lang.String,java.lang.Object>> jsonStream(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 RxStreamingHttpClientjsonStream in interface StreamingHttpClientI - The request body typerequest - The HttpRequest to executePublisher that emits the full HttpResponse objectpublic <I,O> io.reactivex.Flowable<O> jsonStream(HttpRequest<I> request, java.lang.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 RxStreamingHttpClientjsonStream 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> io.reactivex.Flowable<HttpResponse<O>> exchange(HttpRequest<I> request, Argument<O> bodyType, 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 HttpClientexchange in interface RxHttpClientI - 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 java.lang.AutoCloseable> io.reactivex.Flowable<T> connect(java.lang.Class<T> clientEndpointType,
MutableHttpRequest<?> request)
WebSocketClientconnect in interface RxWebSocketClientconnect 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 java.lang.AutoCloseable> io.reactivex.Flowable<T> connect(java.lang.Class<T> clientEndpointType,
java.util.Map<java.lang.String,java.lang.Object> parameters)
RxWebSocketClientWebSocketClient.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 RxWebSocketClientconnect 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 java.io.Closeableclose in interface java.lang.AutoCloseableprotected <I> io.reactivex.functions.Function<java.net.URI,io.reactivex.Flowable<HttpResponse<ByteBuffer<?>>>> buildExchangeStreamPublisher(HttpRequest<I> request)
I - The input typerequest - The requestFunctionprotected <I,O> io.reactivex.functions.Function<java.net.URI,io.reactivex.Flowable<O>> buildJsonStreamPublisher(HttpRequest<?> parentRequest, HttpRequest<I> request, Argument<O> type)
I - The input typeO - The output typeparentRequest - The parent requestrequest - The requesttype - The typeFunctionprotected <I> io.reactivex.functions.Function<java.net.URI,io.reactivex.Flowable<ByteBuffer<?>>> buildDataStreamPublisher(HttpRequest<I> request)
I - The input typerequest - The requestFunctionprotected <I> io.reactivex.Flowable<HttpResponse<java.lang.Object>> buildStreamExchange(@Nullable HttpRequest<?> parentRequest, HttpRequest<I> request, java.net.URI requestURI)
I - The input typeparentRequest - The parent requestrequest - The requestrequestURI - The request URIFlowableprotected <I,O,E> io.reactivex.functions.Function<java.net.URI,org.reactivestreams.Publisher<? extends HttpResponse<O>>> buildExchangePublisher(HttpRequest<?> parentRequest, HttpRequest<I> request, Argument<O> bodyType, 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> org.reactivestreams.Publisher<java.net.URI> resolveRequestURI(HttpRequest<I> request)
I - The input typerequest - The requestPublisher with the resolved URIprotected <I> org.reactivestreams.Publisher<java.net.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> org.reactivestreams.Publisher<java.net.URI> resolveRedirectURI(HttpRequest<?> parentRequest, HttpRequest<I> request)
I - The input typeparentRequest - The parent requestrequest - The redirect location requestPublisher with the resolved URIprotected java.net.URI prependContextPath(java.net.URI requestURI)
requestURI - The request URIprotected java.lang.Object getLoadBalancerDiscriminator()
protected io.netty.channel.ChannelFuture doConnect(HttpRequest<?> request, java.net.URI uri, @Nullable io.netty.handler.ssl.SslContext sslCtx, boolean isStream, java.util.function.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, java.lang.String host, int port, @Nullable io.netty.handler.ssl.SslContext sslCtx, boolean isStream, java.util.function.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.nio.NioEventLoopGroup createEventLoopGroup(HttpClientConfiguration configuration, java.util.concurrent.ThreadFactory threadFactory)
NioEventLoopGroup for this client.configuration - The configurationthreadFactory - The thread factoryprotected io.netty.channel.ChannelFuture doConnect(io.netty.bootstrap.Bootstrap bootstrap,
java.lang.String host,
int port)
bootstrap - The bootstrap instancehost - The hostport - The portprotected io.netty.handler.ssl.SslContext buildSslContext(java.net.URI uriObject)
SslContext for the given URI if necessary.uriObject - The URISslContext instanceprotected void configureProxy(io.netty.channel.ChannelPipeline pipeline,
java.net.Proxy proxy)
pipeline - The pipelineproxy - The proxyprotected void configureProxy(io.netty.channel.ChannelPipeline pipeline,
java.net.Proxy.Type proxyType,
java.net.SocketAddress proxyAddress)
pipeline - The pipelineproxyType - The proxy typeproxyAddress - The proxy addressprotected <I,O> org.reactivestreams.Publisher<HttpResponse<O>> applyFilterToResponsePublisher(HttpRequest<?> parentRequest, HttpRequest<I> request, java.net.URI requestURI, java.util.concurrent.atomic.AtomicReference<HttpRequest> requestWrapper, org.reactivestreams.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, java.net.URI requestURI, MediaType requestContentType, boolean permitsBody, io.reactivex.functions.Consumer<? super java.lang.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 bodyonError - 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, java.lang.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 boolean isClientChannel()
isClientChannel in interface ChannelPipelineCustomizerpublic void doOnConnect(@NonNull
ChannelPipelineListener listener)
ChannelPipelineCustomizerdoOnConnect in interface ChannelPipelineCustomizerlistener - The listener The listener.public io.reactivex.Flowable<MutableHttpResponse<?>> proxy(HttpRequest<?> request)
ProxyHttpClientproxy in interface ProxyHttpClientproxy in interface RxProxyHttpClientrequest - The request