Fix a NoSuchElementException when WebSocketClientHandshaker is used with HttpRequestEncoder. This time for real
This commit is contained in:
parent
978cf0d98a
commit
acde9a3f8e
@ -205,15 +205,21 @@ public abstract class WebSocketClientHandshaker {
|
||||
setHandshakeComplete();
|
||||
|
||||
ChannelPipeline p = channel.pipeline();
|
||||
ChannelHandlerContext ctx = p.context(HttpRequestEncoder.class);
|
||||
ChannelHandlerContext ctx = p.context(HttpResponseDecoder.class);
|
||||
if (ctx == null) {
|
||||
ctx = p.context(HttpClientCodec.class);
|
||||
if (ctx == null) {
|
||||
throw new IllegalStateException("ChannelPipeline does not contain " +
|
||||
"a HttpRequestEncoder or HttpClientCodec");
|
||||
}
|
||||
}
|
||||
p.replaceAndForward(ctx.name(), "ws-decoder", newWebsocketDecoder());
|
||||
} else {
|
||||
if (p.get(HttpRequestEncoder.class) != null) {
|
||||
p.remove(HttpRequestEncoder.class);
|
||||
}
|
||||
p.replaceAndForward(ctx.name(),
|
||||
"ws-decoder", newWebsocketDecoder());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user