Stop decoding after protocol upgrade / Do not use singleDecode option
This commit is contained in:
parent
0f76b3c357
commit
e9f09ea9f5
@ -126,7 +126,8 @@ public abstract class HttpObjectDecoder extends ReplayingDecoder<HttpObjectDecod
|
||||
READ_CHUNKED_CONTENT,
|
||||
READ_CHUNK_DELIMITER,
|
||||
READ_CHUNK_FOOTER,
|
||||
BAD_MESSAGE
|
||||
BAD_MESSAGE,
|
||||
UPGRADED
|
||||
}
|
||||
|
||||
/**
|
||||
@ -354,6 +355,12 @@ public abstract class HttpObjectDecoder extends ReplayingDecoder<HttpObjectDecod
|
||||
case BAD_MESSAGE: {
|
||||
// Keep discarding until disconnection.
|
||||
buffer.skipBytes(actualReadableBytes());
|
||||
break;
|
||||
}
|
||||
case UPGRADED: {
|
||||
// Do not touch anything read - other handler will replace this codec with the upgraded protocol codec to
|
||||
// take the trafic over.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -410,7 +417,17 @@ public abstract class HttpObjectDecoder extends ReplayingDecoder<HttpObjectDecod
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
message = null;
|
||||
HttpMessage message = this.message;
|
||||
this.message = null;
|
||||
|
||||
if (!isDecodingRequest()) {
|
||||
HttpResponse res = (HttpResponse) message;
|
||||
if (res != null && res.getStatus().code() == 101) {
|
||||
checkpoint(State.UPGRADED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
checkpoint(State.SKIP_CONTROL_CHARS);
|
||||
}
|
||||
|
||||
|
@ -157,10 +157,8 @@ public abstract class WebSocketClientHandshaker {
|
||||
"a HttpResponseDecoder or HttpClientCodec"));
|
||||
return promise;
|
||||
}
|
||||
codec.setSingleDecode(true);
|
||||
} else {
|
||||
decoder.setSingleDecode(true);
|
||||
}
|
||||
|
||||
channel.writeAndFlush(request).addListener(new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture future) {
|
||||
|
Loading…
Reference in New Issue
Block a user