Skip to content

Commit 47c55ba

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 20baaa6 commit 47c55ba

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/main/java/com/ning/http/client/providers/netty/channel/ChannelManager.java

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

390-
if (isWebSocket(scheme))
391-
pipeline.replace(HTTP_PROCESSOR, WS_PROCESSOR, wsProcessor);
390+
if (isWebSocket(scheme)) {
391+
pipeline.addAfter(HTTP_PROCESSOR, WS_PROCESSOR, wsProcessor);
392+
pipeline.remove(HTTP_PROCESSOR);
393+
}
392394
}
393395

394396
public String getPoolKey(NettyResponseFuture<?> future) {
@@ -413,7 +415,8 @@ public ClientBootstrap getBootstrap(String scheme, boolean useProxy, boolean use
413415
}
414416

415417
public void upgradePipelineForWebSockets(ChannelPipeline pipeline) {
416-
pipeline.replace(HTTP_HANDLER, WS_ENCODER_HANDLER, new WebSocket08FrameEncoder(true));
418+
pipeline.addAfter(HTTP_HANDLER, WS_ENCODER_HANDLER, new WebSocket08FrameEncoder(true));
419+
pipeline.remove(HTTP_HANDLER);
417420
pipeline.addBefore(WS_PROCESSOR, WS_DECODER_HANDLER, new WebSocket08FrameDecoder(false, false, 10 * 1024));
418421
}
419422

0 commit comments

Comments
 (0)