Skip to content

Commit cce7a8e

Browse files
committed
ChannelManager#updatePipelineForHttpTunneling doesn't position handlers properly wrt additionalChannelInitializer, close AsyncHttpClient#1529
Motivation: 030e3dd introduced a regression where ChannelManager#updatePipelineForHttpTunneling uses `addFirst` to set handlers in the pipeline. But additionalChannelInitializer might have set handlers that require to be in front of the pipeline. Modification: Set position relative to AHC handler. Result: Proper handler positions
1 parent 2064391 commit cce7a8e

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

client/src/main/java/org/asynchttpclient/netty/channel/ChannelManager.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -338,16 +338,15 @@ public void updatePipelineForHttpTunneling(ChannelPipeline pipeline, Uri request
338338
if (pipeline.get(HTTP_CLIENT_CODEC) != null)
339339
pipeline.remove(HTTP_CLIENT_CODEC);
340340

341-
if (requestUri.isSecured())
342-
if (isSslHandlerConfigured(pipeline)) {
343-
pipeline.addAfter(SSL_HANDLER, HTTP_CLIENT_CODEC, newHttpClientCodec());
344-
} else {
345-
pipeline.addFirst(HTTP_CLIENT_CODEC, newHttpClientCodec());
346-
pipeline.addFirst(SSL_HANDLER, createSslHandler(requestUri.getHost(), requestUri.getExplicitPort()));
341+
if (requestUri.isSecured()) {
342+
if (!isSslHandlerConfigured(pipeline)) {
343+
pipeline.addBefore(AHC_HTTP_HANDLER, SSL_HANDLER, createSslHandler(requestUri.getHost(), requestUri.getExplicitPort()));
347344
}
345+
pipeline.addAfter(SSL_HANDLER, HTTP_CLIENT_CODEC, newHttpClientCodec());
348346

349-
else
350-
pipeline.addFirst(HTTP_CLIENT_CODEC, newHttpClientCodec());
347+
} else {
348+
pipeline.addBefore(AHC_HTTP_HANDLER, HTTP_CLIENT_CODEC, newHttpClientCodec());
349+
}
351350

352351
if (requestUri.isWebSocket()) {
353352
pipeline.addAfter(AHC_HTTP_HANDLER, AHC_WS_HANDLER, wsHandler);

0 commit comments

Comments
 (0)