Upgrade and Connection header must be matched in a case-insensitive manner in WebSocket 08 and 13. See #278
This commit is contained in:
parent
980d96cf58
commit
77d2f9c4ef
@ -181,17 +181,21 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String upgrade = response.getHeader(Names.UPGRADE);
|
String upgrade = response.getHeader(Names.UPGRADE);
|
||||||
if (upgrade == null || !upgrade.equals(Values.WEBSOCKET.toLowerCase())) {
|
// Upgrade header should be matched case-insensitive.
|
||||||
|
// See https://github.com/netty/netty/issues/278
|
||||||
|
if (upgrade == null || !upgrade.toLowerCase().equals(Values.WEBSOCKET.toLowerCase())) {
|
||||||
throw new WebSocketHandshakeException("Invalid handshake response upgrade: "
|
throw new WebSocketHandshakeException("Invalid handshake response upgrade: "
|
||||||
+ response.getHeader(Names.UPGRADE));
|
+ response.getHeader(Names.UPGRADE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Connection header should be matched case-insensitive.
|
||||||
|
// See https://github.com/netty/netty/issues/278
|
||||||
String connection = response.getHeader(Names.CONNECTION);
|
String connection = response.getHeader(Names.CONNECTION);
|
||||||
if (connection == null || !connection.equals(Values.UPGRADE)) {
|
if (connection == null || !connection.toLowerCase().equals(Values.UPGRADE.toLowerCase())) {
|
||||||
throw new WebSocketHandshakeException("Invalid handshake response connection: "
|
throw new WebSocketHandshakeException("Invalid handshake response connection: "
|
||||||
+ response.getHeader(Names.CONNECTION));
|
+ response.getHeader(Names.CONNECTION));
|
||||||
}
|
}
|
||||||
|
|
||||||
String accept = response.getHeader(Names.SEC_WEBSOCKET_ACCEPT);
|
String accept = response.getHeader(Names.SEC_WEBSOCKET_ACCEPT);
|
||||||
if (accept == null || !accept.equals(expectedChallengeResponseString)) {
|
if (accept == null || !accept.equals(expectedChallengeResponseString)) {
|
||||||
throw new WebSocketHandshakeException(String.format("Invalid challenge. Actual: %s. Expected: %s", accept,
|
throw new WebSocketHandshakeException(String.format("Invalid challenge. Actual: %s. Expected: %s", accept,
|
||||||
|
@ -178,13 +178,17 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String upgrade = response.getHeader(Names.UPGRADE);
|
String upgrade = response.getHeader(Names.UPGRADE);
|
||||||
if (upgrade == null || !upgrade.equals(Values.WEBSOCKET.toLowerCase())) {
|
// Upgrade header should be matched case-insensitive.
|
||||||
|
// See https://github.com/netty/netty/issues/278
|
||||||
|
if (upgrade == null || !upgrade.toLowerCase().equals(Values.WEBSOCKET.toLowerCase())) {
|
||||||
throw new WebSocketHandshakeException("Invalid handshake response upgrade: "
|
throw new WebSocketHandshakeException("Invalid handshake response upgrade: "
|
||||||
+ response.getHeader(Names.UPGRADE));
|
+ response.getHeader(Names.UPGRADE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Connection header should be matched case-insensitive.
|
||||||
|
// See https://github.com/netty/netty/issues/278
|
||||||
String connection = response.getHeader(Names.CONNECTION);
|
String connection = response.getHeader(Names.CONNECTION);
|
||||||
if (connection == null || !connection.equals(Values.UPGRADE)) {
|
if (connection == null || !connection.toLowerCase().equals(Values.UPGRADE.toLowerCase())) {
|
||||||
throw new WebSocketHandshakeException("Invalid handshake response connection: "
|
throw new WebSocketHandshakeException("Invalid handshake response connection: "
|
||||||
+ response.getHeader(Names.CONNECTION));
|
+ response.getHeader(Names.CONNECTION));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user