diff --git a/webclient/websocket/src/main/java/io/helidon/webclient/websocket/WsClientImpl.java b/webclient/websocket/src/main/java/io/helidon/webclient/websocket/WsClientImpl.java index a2f74a49889..6c9717eed01 100644 --- a/webclient/websocket/src/main/java/io/helidon/webclient/websocket/WsClientImpl.java +++ b/webclient/websocket/src/main/java/io/helidon/webclient/websocket/WsClientImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Oracle and/or its affiliates. + * Copyright (c) 2023, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,6 +74,7 @@ class WsClientImpl implements WsClient { ClientRequestHeaders headers = http1Client.prototype().defaultRequestHeaders(); headers.set(HEADER_UPGRADE_WS); + headers.set(HEADER_CONN_UPGRADE); headers.set(HEADER_WS_VERSION); headers.set(HeaderValues.CONTENT_LENGTH_ZERO); if (clientConfig.protocolConfig().subProtocols().isEmpty()) { diff --git a/webserver/tests/websocket/src/main/java/io/helidon/webserver/tests/websocket/EchoService.java b/webserver/tests/websocket/src/main/java/io/helidon/webserver/tests/websocket/EchoService.java index b2b9a4b44cf..6d554b0e3b2 100644 --- a/webserver/tests/websocket/src/main/java/io/helidon/webserver/tests/websocket/EchoService.java +++ b/webserver/tests/websocket/src/main/java/io/helidon/webserver/tests/websocket/EchoService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Oracle and/or its affiliates. + * Copyright (c) 2022, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import java.util.Optional; import java.util.concurrent.atomic.AtomicReference; +import io.helidon.http.HeaderNames; import io.helidon.http.Headers; import io.helidon.http.HttpPrologue; import io.helidon.http.WritableHeaders; @@ -54,6 +55,10 @@ public void onClose(WsSession session, int status, String reason) { @Override public Optional onHttpUpgrade(HttpPrologue prologue, Headers headers) throws WsUpgradeException { WritableHeaders upgradeHeaders = WritableHeaders.create(); + + if (!headers.get(HeaderNames.CONNECTION).get().equalsIgnoreCase("Upgrade")) { + throw new WsUpgradeException("Must include 'Connection' header with value 'Upgrade'"); + } if (headers.contains(WsUpgrader.PROTOCOL)) { List subProtocols = headers.get(WsUpgrader.PROTOCOL).allValues(true); if (subProtocols.contains("chat")) {