Skip to content

Commit babb5be

Browse files
author
Stephane Landelle
committed
Don't use replace but addAfter+remove so that first frame is not lost, close AsyncHttpClient#471
1 parent 3014f51 commit babb5be

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,10 @@ public void upgradeProtocol(ChannelPipeline pipeline, String scheme, String host
385385
else
386386
pipeline.addFirst(HTTP_HANDLER, newHttpClientCodec());
387387

388-
if (isWebSocket(scheme))
389-
pipeline.replace(HTTP_PROCESSOR, WS_PROCESSOR, wsProcessor);
388+
if (isWebSocket(scheme)) {
389+
pipeline.addAfter(HTTP_PROCESSOR, WS_PROCESSOR, wsProcessor);
390+
pipeline.remove(HTTP_PROCESSOR);
391+
}
390392
}
391393

392394
public String getPoolKey(NettyResponseFuture<?> future) {
@@ -416,7 +418,8 @@ public Bootstrap getBootstrap(UriComponents uri, boolean useProxy, boolean useSS
416418
}
417419

418420
public void upgradePipelineForWebSockets(ChannelPipeline pipeline) {
419-
pipeline.replace(HTTP_HANDLER, WS_ENCODER_HANDLER, new WebSocket08FrameEncoder(true));
421+
pipeline.addAfter(HTTP_HANDLER, WS_ENCODER_HANDLER, new WebSocket08FrameEncoder(true));
422+
pipeline.remove(HTTP_HANDLER);
420423
pipeline.addBefore(WS_PROCESSOR, WS_DECODER_HANDLER, new WebSocket08FrameDecoder(false, false, 10 * 1024));
421424
}
422425

0 commit comments

Comments
 (0)