Skip to content

Commit

Permalink
Fix WebSocket upgrade (#5439)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstepanov authored May 17, 2021
1 parent 398c6f4 commit 85bf1b4
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker;
import io.netty.handler.codec.http.websocketx.WebSocketServerHandshakerFactory;
import io.netty.handler.ssl.SslHandler;
import io.netty.util.AsciiString;
import io.reactivex.BackpressureStrategy;
import io.reactivex.Flowable;
import io.reactivex.Single;
Expand Down Expand Up @@ -77,6 +78,7 @@ public class NettyServerWebSocketUpgradeHandler extends SimpleChannelInboundHand
public static final String SCHEME_SECURE_WEBSOCKET = "wss://";

private static final Logger LOG = LoggerFactory.getLogger(NettyServerWebSocketUpgradeHandler.class);
private static final AsciiString WEB_SOCKET_HEADER_VALUE = AsciiString.cached("websocket");

private final Router router;
private final RequestBinderRegistry binderRegistry;
Expand Down Expand Up @@ -115,9 +117,11 @@ public NettyServerWebSocketUpgradeHandler(
public boolean acceptInboundMessage(Object msg) {
if (msg instanceof NettyHttpRequest) {
NettyHttpRequest<?> request = (NettyHttpRequest) msg;
return request.getNativeRequest().headers().contains(HttpHeaderNames.CONNECTION.toString(), HttpHeaderValues.UPGRADE, true);
if (request.getNativeRequest().headers().contains(HttpHeaderNames.CONNECTION.toString(), HttpHeaderValues.UPGRADE, true)) {
return request.getNativeRequest().headers().containsValue(HttpHeaderNames.UPGRADE, WEB_SOCKET_HEADER_VALUE, true);
}
}
return false;
return false;
}

@Override
Expand Down

0 comments on commit 85bf1b4

Please sign in to comment.