Class ChannelManager


  • public class ChannelManager
    extends Object
    • Constructor Detail

      • ChannelManager

        public ChannelManager​(AsyncHttpClientConfig config,
                              io.netty.util.Timer nettyTimer)
    • Method Detail

      • isSslHandlerConfigured

        public static boolean isSslHandlerConfigured​(io.netty.channel.ChannelPipeline pipeline)
      • configureBootstraps

        public void configureBootstraps​(NettyRequestSender requestSender)
      • tryToOfferChannelToPool

        public final void tryToOfferChannelToPool​(io.netty.channel.Channel channel,
                                                  AsyncHandler<?> asyncHandler,
                                                  boolean keepAlive,
                                                  Object partitionKey)
      • registerHttp2Connection

        public void registerHttp2Connection​(Object partitionKey,
                                            io.netty.channel.Channel channel)
        Registers an HTTP/2 connection in the registry for the given partition key. The connection stays in the registry (not the regular pool) to allow multiplexing — multiple requests can share the same connection concurrently.
      • removeHttp2Connection

        public void removeHttp2Connection​(Object partitionKey,
                                          io.netty.channel.Channel channel)
        Removes an HTTP/2 connection from the registry, but only if it's the currently registered connection for that partition key (avoids removing a replacement connection).
      • pollHttp2Connection

        public io.netty.channel.Channel pollHttp2Connection​(Object partitionKey)
        Returns an active, non-draining HTTP/2 connection for the given partition key, or null. Unlike the regular pool, this does NOT remove the connection — it remains available for concurrent multiplexed requests.
      • pollHttp2

        public io.netty.channel.Channel pollHttp2​(Uri uri,
                                                  String virtualHost,
                                                  ProxyServer proxy,
                                                  ChannelPoolPartitioning connectionPoolPartitioning)
        Polls for an HTTP/2 connection by URI/virtualHost/proxy, using the same partition key logic as the regular pool. Returns the connection without removing it from the registry.
      • removeAll

        public void removeAll​(io.netty.channel.Channel connection)
      • close

        public void close()
      • closeChannel

        public void closeChannel​(io.netty.channel.Channel channel)
      • registerOpenChannel

        public void registerOpenChannel​(io.netty.channel.Channel channel)
      • updatePipelineForHttpTunneling

        public io.netty.util.concurrent.Future<io.netty.channel.Channel> updatePipelineForHttpTunneling​(io.netty.channel.ChannelPipeline pipeline,
                                                                                                        Uri requestUri)
      • updatePipelineForHttpsTunneling

        public io.netty.util.concurrent.Future<io.netty.channel.Channel> updatePipelineForHttpsTunneling​(io.netty.channel.ChannelPipeline pipeline,
                                                                                                         Uri requestUri,
                                                                                                         ProxyServer proxyServer)
      • addSslHandler

        public io.netty.handler.ssl.SslHandler addSslHandler​(io.netty.channel.ChannelPipeline pipeline,
                                                             Uri uri,
                                                             String virtualHost,
                                                             boolean hasSocksProxyHandler)
      • getBootstrap

        public io.netty.util.concurrent.Future<io.netty.bootstrap.Bootstrap> getBootstrap​(Uri uri,
                                                                                          io.netty.resolver.NameResolver<InetAddress> nameResolver,
                                                                                          ProxyServer proxy)
      • isHttp2

        public static boolean isHttp2​(io.netty.channel.Channel channel)
        Checks whether the given channel is an HTTP/2 connection (i.e. has the HTTP/2 multiplex handler installed).
      • isHttp2StreamChannel

        public static boolean isHttp2StreamChannel​(io.netty.channel.Channel channel)
        Checks whether the given channel is an HTTP/2 stream child channel. Stream channels are single-use and don't support HTTP/1.1 operations like draining or pipeline modification.
      • getHttp2Handler

        public Http2Handler getHttp2Handler()
        Returns the shared Http2Handler instance for use with stream child channels.
      • upgradePipelineToHttp2

        public void upgradePipelineToHttp2​(io.netty.channel.ChannelPipeline pipeline)
        Upgrades the pipeline from HTTP/1.1 to HTTP/2 after ALPN negotiates "h2". Removes HTTP/1.1 handlers and adds Http2FrameCodec + Http2MultiplexHandler. The per-stream Http2Handler is added separately on each stream child channel.
      • upgradePipelineForWebSockets

        public void upgradePipelineForWebSockets​(io.netty.channel.ChannelPipeline pipeline)
      • drainChannelAndOffer

        public void drainChannelAndOffer​(io.netty.channel.Channel channel,
                                         NettyResponseFuture<?> future)
      • drainChannelAndOffer

        public void drainChannelAndOffer​(io.netty.channel.Channel channel,
                                         NettyResponseFuture<?> future,
                                         boolean keepAlive,
                                         Object partitionKey)
      • getEventLoopGroup

        public io.netty.channel.EventLoopGroup getEventLoopGroup()
      • getAddressResolverGroup

        @Nullable
        public @Nullable io.netty.resolver.AddressResolverGroup<InetSocketAddress> getAddressResolverGroup()
        Return the AddressResolverGroup used for async DNS resolution, or null if per-request name resolvers should be used (legacy behavior).
      • isOpen

        public boolean isOpen()
      • isHttp2CleartextEnabled

        public boolean isHttp2CleartextEnabled()