5858import org .asynchttpclient .netty .channel .pool .DefaultChannelPool ;
5959import org .asynchttpclient .netty .channel .pool .NoopChannelPool ;
6060import org .asynchttpclient .netty .handler .HttpProtocol ;
61- import org .asynchttpclient .netty .handler .Processor ;
61+ import org .asynchttpclient .netty .handler .AsyncHttpClientHandler ;
6262import org .asynchttpclient .netty .handler .WebSocketProtocol ;
6363import org .asynchttpclient .netty .request .NettyRequestSender ;
6464import org .asynchttpclient .netty .ssl .DefaultSslEngineFactory ;
7070public class ChannelManager {
7171
7272 private static final Logger LOGGER = LoggerFactory .getLogger (ChannelManager .class );
73- public static final String HTTP_HANDLER = "httpHandler" ;
74- public static final String SSL_HANDLER = "sslHandler" ;
75- public static final String HTTP_PROCESSOR = "httpProcessor" ;
76- public static final String WS_PROCESSOR = "wsProcessor" ;
73+ public static final String HTTP_CLIENT_CODEC = "http" ;
74+ public static final String SSL_HANDLER = "ssl" ;
7775 public static final String DEFLATER_HANDLER = "deflater" ;
7876 public static final String INFLATER_HANDLER = "inflater" ;
79- public static final String CHUNKED_WRITER_HANDLER = "chunkedWriter " ;
77+ public static final String CHUNKED_WRITER_HANDLER = "chunked-writer " ;
8078 public static final String WS_DECODER_HANDLER = "ws-decoder" ;
8179 public static final String WS_FRAME_AGGREGATOR = "ws-aggregator" ;
8280 public static final String WS_ENCODER_HANDLER = "ws-encoder" ;
81+ public static final String AHC_HTTP_HANDLER = "ahc-http" ;
82+ public static final String AHC_WS_HANDLER = "ahc-ws" ;
8383
8484 private final AsyncHttpClientConfig config ;
8585 private final SslEngineFactory sslEngineFactory ;
@@ -102,7 +102,7 @@ public class ChannelManager {
102102 private final ConcurrentHashMapV8 <Channel , Object > channelId2PartitionKey ;
103103 private final ConcurrentHashMapV8 .Fun <Object , Semaphore > semaphoreComputer ;
104104
105- private Processor wsProcessor ;
105+ private AsyncHttpClientHandler wsHandler ;
106106
107107 public ChannelManager (final AsyncHttpClientConfig config , Timer nettyTimer ) {
108108
@@ -237,19 +237,19 @@ private Class<? extends Channel> getEpollSocketChannelClass() {
237237 public void configureBootstraps (NettyRequestSender requestSender ) {
238238
239239 HttpProtocol httpProtocol = new HttpProtocol (this , config , requestSender );
240- final Processor httpProcessor = new Processor (config , this , requestSender , httpProtocol );
240+ final AsyncHttpClientHandler httpHandler = new AsyncHttpClientHandler (config , this , requestSender , httpProtocol );
241241
242242 WebSocketProtocol wsProtocol = new WebSocketProtocol (this , config , requestSender );
243- wsProcessor = new Processor (config , this , requestSender , wsProtocol );
243+ wsHandler = new AsyncHttpClientHandler (config , this , requestSender , wsProtocol );
244244
245245 httpBootstrap .handler (new ChannelInitializer <Channel >() {
246246 @ Override
247247 protected void initChannel (Channel ch ) throws Exception {
248248 ch .pipeline ()//
249- .addLast (HTTP_HANDLER , newHttpClientCodec ())//
249+ .addLast (HTTP_CLIENT_CODEC , newHttpClientCodec ())//
250250 .addLast (INFLATER_HANDLER , newHttpContentDecompressor ())//
251251 .addLast (CHUNKED_WRITER_HANDLER , new ChunkedWriteHandler ())//
252- .addLast (HTTP_PROCESSOR , httpProcessor );
252+ .addLast (AHC_HTTP_HANDLER , httpHandler );
253253
254254 ch .config ().setOption (ChannelOption .AUTO_READ , false );
255255
@@ -262,8 +262,8 @@ protected void initChannel(Channel ch) throws Exception {
262262 @ Override
263263 protected void initChannel (Channel ch ) throws Exception {
264264 ch .pipeline ()//
265- .addLast (HTTP_HANDLER , newHttpClientCodec ())//
266- .addLast (WS_PROCESSOR , wsProcessor );
265+ .addLast (HTTP_CLIENT_CODEC , newHttpClientCodec ())//
266+ .addLast (AHC_WS_HANDLER , wsHandler );
267267
268268 if (config .getWsAdditionalPipelineInitializer () != null )
269269 config .getWsAdditionalPipelineInitializer ().initPipeline (ch .pipeline ());
@@ -405,23 +405,23 @@ public static boolean isSslHandlerConfigured(ChannelPipeline pipeline) {
405405 }
406406
407407 public void upgradeProtocol (ChannelPipeline pipeline , Uri requestUri ) throws SSLException {
408- if (pipeline .get (HTTP_HANDLER ) != null )
409- pipeline .remove (HTTP_HANDLER );
408+ if (pipeline .get (HTTP_CLIENT_CODEC ) != null )
409+ pipeline .remove (HTTP_CLIENT_CODEC );
410410
411411 if (requestUri .isSecured ())
412412 if (isSslHandlerConfigured (pipeline )) {
413- pipeline .addAfter (SSL_HANDLER , HTTP_HANDLER , newHttpClientCodec ());
413+ pipeline .addAfter (SSL_HANDLER , HTTP_CLIENT_CODEC , newHttpClientCodec ());
414414 } else {
415- pipeline .addFirst (HTTP_HANDLER , newHttpClientCodec ());
415+ pipeline .addFirst (HTTP_CLIENT_CODEC , newHttpClientCodec ());
416416 pipeline .addFirst (SSL_HANDLER , createSslHandler (requestUri .getHost (), requestUri .getExplicitPort ()));
417417 }
418418
419419 else
420- pipeline .addFirst (HTTP_HANDLER , newHttpClientCodec ());
420+ pipeline .addFirst (HTTP_CLIENT_CODEC , newHttpClientCodec ());
421421
422422 if (requestUri .isWebSocket ()) {
423- pipeline .addAfter (HTTP_PROCESSOR , WS_PROCESSOR , wsProcessor );
424- pipeline .remove (HTTP_PROCESSOR );
423+ pipeline .addAfter (AHC_HTTP_HANDLER , AHC_WS_HANDLER , wsHandler );
424+ pipeline .remove (AHC_HTTP_HANDLER );
425425 }
426426 }
427427
@@ -477,9 +477,9 @@ public Bootstrap getBootstrap(Uri uri, ProxyServer proxy) {
477477 }
478478
479479 public void upgradePipelineForWebSockets (ChannelPipeline pipeline ) {
480- pipeline .addAfter (HTTP_HANDLER , WS_ENCODER_HANDLER , new WebSocket08FrameEncoder (true ));
481- pipeline .remove (HTTP_HANDLER );
482- pipeline .addBefore (WS_PROCESSOR , WS_DECODER_HANDLER , new WebSocket08FrameDecoder (false , false , config .getWebSocketMaxFrameSize ()));
480+ pipeline .addAfter (HTTP_CLIENT_CODEC , WS_ENCODER_HANDLER , new WebSocket08FrameEncoder (true ));
481+ pipeline .remove (HTTP_CLIENT_CODEC );
482+ pipeline .addBefore (AHC_WS_HANDLER , WS_DECODER_HANDLER , new WebSocket08FrameDecoder (false , false , config .getWebSocketMaxFrameSize ()));
483483 pipeline .addAfter (WS_DECODER_HANDLER , WS_FRAME_AGGREGATOR , new WebSocketFrameAggregator (config .getWebSocketMaxBufferSize ()));
484484 }
485485
0 commit comments