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 17, 2024
1 parent 22d4e62 commit 2425ed2
Showing 1 changed file with 3 additions and 1 deletion.
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,7 +128,8 @@ public void connect(URI uri, WsListener listener) {
ClientWsConnection session;
try (HttpClientResponse response = upgradeResponse.response()) {
ClientResponseHeaders responseHeaders = response.headers();
if (!responseHeaders.contains(HEADER_CONN_UPGRADE)) {
if (!responseHeaders.contains(HEADER_CONN_UPGRADE)
&& !responseHeaders.contains(HEADER_CONN_UPGRADE_LOWERCASE)) {
throw new WsClientException("Failed to upgrade to WebSocket, expected Connection: Upgrade header. Headers: "
+ responseHeaders);
}
Expand Down

0 comments on commit 2425ed2

Please sign in to comment.