Fix a bug where first websocket frame is discarded (#332)

This commit is contained in:
Trustin Lee 2012-05-30 19:18:08 -07:00
parent e2a7462d70
commit 743596aaea
3 changed files with 7 additions and 6 deletions

View File

@ -152,7 +152,7 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
request.addHeader(Names.ORIGIN, originValue);
request.addHeader(Names.SEC_WEBSOCKET_KEY1, key1);
request.addHeader(Names.SEC_WEBSOCKET_KEY2, key2);
String expectedSubprotocol = this.getExpectedSubprotocol();
String expectedSubprotocol = getExpectedSubprotocol();
if (expectedSubprotocol != null && !expectedSubprotocol.equals("")) {
request.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
}
@ -223,9 +223,8 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
String subprotocol = response.getHeader(Names.SEC_WEBSOCKET_PROTOCOL);
setActualSubprotocol(subprotocol);
channel.pipeline().replace(
HttpResponseDecoder.class, "ws-decoder",
new WebSocket00FrameDecoder(getMaxFramePayloadLength()));
channel.pipeline().get(HttpResponseDecoder.class).replace(
"ws-decoder", new WebSocket00FrameDecoder(getMaxFramePayloadLength()));
setHandshakeComplete();
}

View File

@ -200,7 +200,8 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
String subprotocol = response.getHeader(Names.SEC_WEBSOCKET_PROTOCOL);
setActualSubprotocol(subprotocol);
channel.pipeline().replace(HttpResponseDecoder.class, "ws-decoder",
channel.pipeline().get(HttpResponseDecoder.class).replace(
"ws-decoder",
new WebSocket08FrameDecoder(false, allowExtensions, getMaxFramePayloadLength()));
setHandshakeComplete();

View File

@ -200,7 +200,8 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
String subprotocol = response.getHeader(Names.SEC_WEBSOCKET_PROTOCOL);
setActualSubprotocol(subprotocol);
channel.pipeline().replace(HttpResponseDecoder.class, "ws-decoder",
channel.pipeline().get(HttpResponseDecoder.class).replace(
"ws-decoder",
new WebSocket13FrameDecoder(false, allowExtensions, getMaxFramePayloadLength()));
setHandshakeComplete();