58
58
import org .asynchttpclient .netty .channel .pool .DefaultChannelPool ;
59
59
import org .asynchttpclient .netty .channel .pool .NoopChannelPool ;
60
60
import org .asynchttpclient .netty .handler .HttpProtocol ;
61
- import org .asynchttpclient .netty .handler .Processor ;
61
+ import org .asynchttpclient .netty .handler .AsyncHttpClientHandler ;
62
62
import org .asynchttpclient .netty .handler .WebSocketProtocol ;
63
63
import org .asynchttpclient .netty .request .NettyRequestSender ;
64
64
import org .asynchttpclient .netty .ssl .DefaultSslEngineFactory ;
70
70
public class ChannelManager {
71
71
72
72
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" ;
77
75
public static final String DEFLATER_HANDLER = "deflater" ;
78
76
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 " ;
80
78
public static final String WS_DECODER_HANDLER = "ws-decoder" ;
81
79
public static final String WS_FRAME_AGGREGATOR = "ws-aggregator" ;
82
80
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" ;
83
83
84
84
private final AsyncHttpClientConfig config ;
85
85
private final SslEngineFactory sslEngineFactory ;
@@ -102,7 +102,7 @@ public class ChannelManager {
102
102
private final ConcurrentHashMapV8 <Channel , Object > channelId2PartitionKey ;
103
103
private final ConcurrentHashMapV8 .Fun <Object , Semaphore > semaphoreComputer ;
104
104
105
- private Processor wsProcessor ;
105
+ private AsyncHttpClientHandler wsHandler ;
106
106
107
107
public ChannelManager (final AsyncHttpClientConfig config , Timer nettyTimer ) {
108
108
@@ -237,19 +237,19 @@ private Class<? extends Channel> getEpollSocketChannelClass() {
237
237
public void configureBootstraps (NettyRequestSender requestSender ) {
238
238
239
239
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 );
241
241
242
242
WebSocketProtocol wsProtocol = new WebSocketProtocol (this , config , requestSender );
243
- wsProcessor = new Processor (config , this , requestSender , wsProtocol );
243
+ wsHandler = new AsyncHttpClientHandler (config , this , requestSender , wsProtocol );
244
244
245
245
httpBootstrap .handler (new ChannelInitializer <Channel >() {
246
246
@ Override
247
247
protected void initChannel (Channel ch ) throws Exception {
248
248
ch .pipeline ()//
249
- .addLast (HTTP_HANDLER , newHttpClientCodec ())//
249
+ .addLast (HTTP_CLIENT_CODEC , newHttpClientCodec ())//
250
250
.addLast (INFLATER_HANDLER , newHttpContentDecompressor ())//
251
251
.addLast (CHUNKED_WRITER_HANDLER , new ChunkedWriteHandler ())//
252
- .addLast (HTTP_PROCESSOR , httpProcessor );
252
+ .addLast (AHC_HTTP_HANDLER , httpHandler );
253
253
254
254
ch .config ().setOption (ChannelOption .AUTO_READ , false );
255
255
@@ -262,8 +262,8 @@ protected void initChannel(Channel ch) throws Exception {
262
262
@ Override
263
263
protected void initChannel (Channel ch ) throws Exception {
264
264
ch .pipeline ()//
265
- .addLast (HTTP_HANDLER , newHttpClientCodec ())//
266
- .addLast (WS_PROCESSOR , wsProcessor );
265
+ .addLast (HTTP_CLIENT_CODEC , newHttpClientCodec ())//
266
+ .addLast (AHC_WS_HANDLER , wsHandler );
267
267
268
268
if (config .getWsAdditionalPipelineInitializer () != null )
269
269
config .getWsAdditionalPipelineInitializer ().initPipeline (ch .pipeline ());
@@ -405,23 +405,23 @@ public static boolean isSslHandlerConfigured(ChannelPipeline pipeline) {
405
405
}
406
406
407
407
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 );
410
410
411
411
if (requestUri .isSecured ())
412
412
if (isSslHandlerConfigured (pipeline )) {
413
- pipeline .addAfter (SSL_HANDLER , HTTP_HANDLER , newHttpClientCodec ());
413
+ pipeline .addAfter (SSL_HANDLER , HTTP_CLIENT_CODEC , newHttpClientCodec ());
414
414
} else {
415
- pipeline .addFirst (HTTP_HANDLER , newHttpClientCodec ());
415
+ pipeline .addFirst (HTTP_CLIENT_CODEC , newHttpClientCodec ());
416
416
pipeline .addFirst (SSL_HANDLER , createSslHandler (requestUri .getHost (), requestUri .getExplicitPort ()));
417
417
}
418
418
419
419
else
420
- pipeline .addFirst (HTTP_HANDLER , newHttpClientCodec ());
420
+ pipeline .addFirst (HTTP_CLIENT_CODEC , newHttpClientCodec ());
421
421
422
422
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 );
425
425
}
426
426
}
427
427
@@ -477,9 +477,9 @@ public Bootstrap getBootstrap(Uri uri, ProxyServer proxy) {
477
477
}
478
478
479
479
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 ()));
483
483
pipeline .addAfter (WS_DECODER_HANDLER , WS_FRAME_AGGREGATOR , new WebSocketFrameAggregator (config .getWebSocketMaxBufferSize ()));
484
484
}
485
485
0 commit comments