fix(gateway): test existance of Upgrade into Connection header values
Fixe gravitee-io/issues#4768
@@ -56,9 +56,15 @@ public class VertxWebSocketReactorHandler extends VertxReactorHandler {
private boolean isWebSocket(HttpServerRequest httpServerRequest) {
String connectionHeader = httpServerRequest.getHeader(HttpHeaders.CONNECTION);
String upgradeHeader = httpServerRequest.getHeader(HttpHeaders.UPGRADE);
-
+ boolean isUpgrade = false;
+ if (connectionHeader != null) {
+ String[] connectionParts = connectionHeader.split(",");
+ for (int i = 0; i < connectionParts.length && !isUpgrade; ++i) {
+ isUpgrade = HttpHeaderValues.UPGRADE.contentEqualsIgnoreCase(connectionParts[i].trim());
+ }
+ }
return httpServerRequest.method() == HttpMethod.GET &&
- HttpHeaderValues.UPGRADE.contentEqualsIgnoreCase(connectionHeader) &&
+ isUpgrade &&
HttpHeaderValues.WEBSOCKET.contentEqualsIgnoreCase(upgradeHeader);
}
}
