6565
6666public class ChannelManager {
6767
68- public static final String PINNED_ENTRY = "entry" ;
6968 public static final String HTTP_CLIENT_CODEC = "http" ;
7069 public static final String SSL_HANDLER = "ssl" ;
7170 public static final String SOCKS_HANDLER = "socks" ;
@@ -208,22 +207,19 @@ public void configureBootstraps(NettyRequestSender requestSender) {
208207 final AsyncHttpClientHandler httpHandler = new HttpHandler (config , this , requestSender );
209208 wsHandler = new WebSocketHandler (config , this , requestSender );
210209
211- final NoopHandler pinnedEntry = new NoopHandler ();
212-
213210 final LoggingHandler loggingHandler = new LoggingHandler (LogLevel .TRACE );
214211
215212 httpBootstrap .handler (new ChannelInitializer <Channel >() {
216213 @ Override
217214 protected void initChannel (Channel ch ) {
218215 ChannelPipeline pipeline = ch .pipeline ()
219- .addLast (PINNED_ENTRY , pinnedEntry )
220216 .addLast (HTTP_CLIENT_CODEC , newHttpClientCodec ())
221217 .addLast (INFLATER_HANDLER , newHttpContentDecompressor ())
222218 .addLast (CHUNKED_WRITER_HANDLER , new ChunkedWriteHandler ())
223219 .addLast (AHC_HTTP_HANDLER , httpHandler );
224220
225221 if (LOGGER .isTraceEnabled ()) {
226- pipeline .addAfter ( PINNED_ENTRY , LOGGING_HANDLER , loggingHandler );
222+ pipeline .addFirst ( LOGGING_HANDLER , loggingHandler );
227223 }
228224
229225 if (config .getHttpAdditionalChannelInitializer () != null )
@@ -235,7 +231,6 @@ protected void initChannel(Channel ch) {
235231 @ Override
236232 protected void initChannel (Channel ch ) {
237233 ChannelPipeline pipeline = ch .pipeline ()
238- .addLast (PINNED_ENTRY , pinnedEntry )
239234 .addLast (HTTP_CLIENT_CODEC , newHttpClientCodec ())
240235 .addLast (AHC_WS_HANDLER , wsHandler );
241236
@@ -244,7 +239,7 @@ protected void initChannel(Channel ch) {
244239 }
245240
246241 if (LOGGER .isDebugEnabled ()) {
247- pipeline .addAfter ( PINNED_ENTRY , LOGGING_HANDLER , loggingHandler );
242+ pipeline .addFirst ( LOGGING_HANDLER , loggingHandler );
248243 }
249244
250245 if (config .getWsAdditionalChannelInitializer () != null )
@@ -347,12 +342,12 @@ public void updatePipelineForHttpTunneling(ChannelPipeline pipeline, Uri request
347342 if (isSslHandlerConfigured (pipeline )) {
348343 pipeline .addAfter (SSL_HANDLER , HTTP_CLIENT_CODEC , newHttpClientCodec ());
349344 } else {
350- pipeline .addAfter ( PINNED_ENTRY , HTTP_CLIENT_CODEC , newHttpClientCodec ());
351- pipeline .addAfter ( PINNED_ENTRY , SSL_HANDLER , createSslHandler (requestUri .getHost (), requestUri .getExplicitPort ()));
345+ pipeline .addFirst ( HTTP_CLIENT_CODEC , newHttpClientCodec ());
346+ pipeline .addFirst ( SSL_HANDLER , createSslHandler (requestUri .getHost (), requestUri .getExplicitPort ()));
352347 }
353348
354349 else
355- pipeline .addAfter ( PINNED_ENTRY , HTTP_CLIENT_CODEC , newHttpClientCodec ());
350+ pipeline .addFirst ( HTTP_CLIENT_CODEC , newHttpClientCodec ());
356351
357352 if (requestUri .isWebSocket ()) {
358353 pipeline .addAfter (AHC_HTTP_HANDLER , AHC_WS_HANDLER , wsHandler );
@@ -383,7 +378,7 @@ public SslHandler addSslHandler(ChannelPipeline pipeline, Uri uri, String virtua
383378 if (hasSocksProxyHandler )
384379 pipeline .addAfter (SOCKS_HANDLER , SSL_HANDLER , sslHandler );
385380 else
386- pipeline .addAfter ( PINNED_ENTRY , SSL_HANDLER , sslHandler );
381+ pipeline .addFirst ( SSL_HANDLER , sslHandler );
387382 return sslHandler ;
388383 }
389384
@@ -426,7 +421,7 @@ protected void initChannel(Channel channel) throws Exception {
426421 default :
427422 throw new IllegalArgumentException ("Only SOCKS4 and SOCKS5 supported at the moment." );
428423 }
429- channel .pipeline ().addAfter ( PINNED_ENTRY , SOCKS_HANDLER , socksProxyHandler );
424+ channel .pipeline ().addFirst ( SOCKS_HANDLER , socksProxyHandler );
430425 }
431426 });
432427 promise .setSuccess (socksBootstrap );
0 commit comments