Skip to content

Commit

Permalink
WsClient accept connection upgrade lowercase
Browse files Browse the repository at this point in the history
Signed-off-by: tvallin <thibault.vallin@oracle.com>
  • Loading branch information
tvallin committed Apr 18, 2024
1 parent 22d4e62 commit 216b52c
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class WsClientImpl implements WsClient {

private static final System.Logger LOGGER = System.getLogger(WsClient.class.getName());
private static final Header HEADER_CONN_UPGRADE = HeaderValues.create(HeaderNames.CONNECTION, "Upgrade");
private static final Header HEADER_CONN_UPGRADE_LOWERCASE = HeaderValues.create(HeaderNames.CONNECTION, "upgrade");
private static final HeaderName HEADER_WS_ACCEPT = HeaderNames.create("Sec-WebSocket-Accept");
private static final HeaderName HEADER_WS_KEY = HeaderNames.create("Sec-WebSocket-Key");
private static final LazyValue<Random> RANDOM = LazyValue.create(SecureRandom::new);
Expand Down Expand Up @@ -127,9 +128,10 @@ public void connect(URI uri, WsListener listener) {
ClientWsConnection session;
try (HttpClientResponse response = upgradeResponse.response()) {
ClientResponseHeaders responseHeaders = response.headers();
if (!responseHeaders.contains(HEADER_CONN_UPGRADE)) {
throw new WsClientException("Failed to upgrade to WebSocket, expected Connection: Upgrade header. Headers: "
+ responseHeaders);
if (!responseHeaders.contains(HEADER_CONN_UPGRADE)
&& !responseHeaders.contains(HEADER_CONN_UPGRADE_LOWERCASE)) {
throw new WsClientException("Failed to upgrade to WebSocket, expected one of "
+ "[Connection: Upgrade, Connection: upgrade] header. Headers: " + responseHeaders);
}
if (!responseHeaders.contains(HEADER_UPGRADE_WS)) {
throw new WsClientException("Failed to upgrade to WebSocket, expected Upgrade: websocket header. Headers: "
Expand Down

0 comments on commit 216b52c

Please sign in to comment.