Skip to content

Web Inspector: Network.setExtraHTTPHeaders does not affect WebSocket - #67097

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
dcrousso:eng/317001
Jun 18, 2026
Merged

webkit-commit-queue merged 1 commit into
WebKit:mainfrom
dcrousso:eng/317001

Conversation

@dcrousso

@dcrousso dcrousso commented Jun 12, 2026 •

Copy link
Copy Markdown
Member

1e9d5a1

Web Inspector: `Network.setExtraHTTPHeaders` does not affect `WebSocket`
https://bugs.webkit.org/show_bug.cgi?id=317001

Reviewed by Youenn Fablet.

Test: http/tests/websocket/tests/hybi/inspector/set-extra-http-headers.html

* Source/WebCore/Modules/websockets/WebSocketHandshake.h:
* Source/WebCore/Modules/websockets/WebSocketHandshake.cpp:
(WebCore::isStandardWebSocketHandshakeRequestHeader): Added.
(WebCore::WebSocketHandshake::setClientHandshakeRequestHeaders): Added.
(WebCore::WebSocketHandshake::clientHandshakeMessage const):
(WebCore::WebSocketHandshake::clientHandshakeRequest const):
Allow the caller to set additional headers that will be included in the handshake message/request.

* Source/WebKit/NetworkProcess/curl/WebSocketTaskCurl.cpp:
(WebKit::WebSocketTask::didOpen):
* Source/WebKitLegacy/WebCoreSupport/WebSocketChannel.cpp:
(WebCore::WebSocketChannel::didOpenSocketStream):
Make sure to forward any additional headers.

* Source/WebKit/WebProcess/Network/WebSocketChannel.cpp:
(WebKit::WebSocketChannel::connect):
(WebKit::WebSocketChannel::didSendHandshakeRequest):
* Source/WebCore/Modules/websockets/WebSocketChannelInspector.h:
* Source/WebCore/Modules/websockets/WebSocketChannelInspector.cpp:
(WebCore::WebSocketChannelInspector::willSendWebSocketHandshakeRequest const):
(WebCore::WebSocketChannelInspector::didSendWebSocketHandshakeRequest const): Added.
* Source/WebCore/inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::willSendWebSocketHandshakeRequest):
(WebCore::InspectorInstrumentation::didSendWebSocketHandshakeRequest): Added.
* Source/WebCore/inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::willSendWebSocketHandshakeRequestImpl):
(WebCore::InspectorInstrumentation::didSendWebSocketHandshakeRequestImpl): Added.
* Source/WebCore/inspector/LegacyWebSocketInspectorInstrumentation.h:
* Source/WebCore/inspector/LegacyWebSocketInspectorInstrumentation.cpp:
(WebCore::LegacyWebSocketInspectorInstrumentation::willSendWebSocketHandshakeRequest):
(WebCore::LegacyWebSocketInspectorInstrumentation::didSendWebSocketHandshakeRequest): Added.
* Source/WebCore/inspector/agents/InspectorNetworkAgent.h:
* Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:
(WebCore::InspectorNetworkAgent::willSendWebSocketHandshakeRequest):
(WebCore::InspectorNetworkAgent::didSendWebSocketHandshakeRequest): Added.
(WebCore::InspectorNetworkAgent::enable):
Rename the existing `willSendWebSocketHandshakeRequest` to `didSendWebSocketHandshakeRequest` since it actually instrumented after the request was sent.
Add a new `willSendWebSocketHandshakeRequest` that allows Web Inspector to modify the request before it is sent.

* LayoutTests/http/tests/websocket/tests/hybi/inspector/echo-headers_wsh.py: Added.
* LayoutTests/http/tests/websocket/tests/hybi/inspector/set-extra-http-headers.html: Added.
* LayoutTests/http/tests/websocket/tests/hybi/inspector/set-extra-http-headers-expected.txt: Added.

Canonical link: https://commits.webkit.org/315465@main

8ceb66f

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ❌ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ❌ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 api-mac-debug ✅ 🛠 gtk3-libwebrtc
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 ios-safer-cpp ❌ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision ❌ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🛠 vision-sim ❌ 🧪 mac-intel-wk2 ✅ 🛠 playstation
✅ 🧪 vision-wk2 ✅ 🛠 mac-safer-cpp
✅ 🛠 tv ✅ 🧪 mac-site-isolation
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@dcrousso dcrousso self-assigned this Jun 12, 2026
@dcrousso dcrousso added the Web Inspector Bugs related to the WebKit Web Inspector. label Jun 12, 2026
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 13, 2026
@dcrousso
dcrousso requested review from charliewolfe and youennf June 16, 2026 16:59
@dcrousso dcrousso added merge-queue Applied to send a pull request to merge-queue and removed merging-blocked Applied to prevent a change from being merged labels Jun 18, 2026
https://bugs.webkit.org/show_bug.cgi?id=317001

Reviewed by Youenn Fablet.

Test: http/tests/websocket/tests/hybi/inspector/set-extra-http-headers.html

* Source/WebCore/Modules/websockets/WebSocketHandshake.h:
* Source/WebCore/Modules/websockets/WebSocketHandshake.cpp:
(WebCore::isStandardWebSocketHandshakeRequestHeader): Added.
(WebCore::WebSocketHandshake::setClientHandshakeRequestHeaders): Added.
(WebCore::WebSocketHandshake::clientHandshakeMessage const):
(WebCore::WebSocketHandshake::clientHandshakeRequest const):
Allow the caller to set additional headers that will be included in the handshake message/request.

* Source/WebKit/NetworkProcess/curl/WebSocketTaskCurl.cpp:
(WebKit::WebSocketTask::didOpen):
* Source/WebKitLegacy/WebCoreSupport/WebSocketChannel.cpp:
(WebCore::WebSocketChannel::didOpenSocketStream):
Make sure to forward any additional headers.

* Source/WebKit/WebProcess/Network/WebSocketChannel.cpp:
(WebKit::WebSocketChannel::connect):
(WebKit::WebSocketChannel::didSendHandshakeRequest):
* Source/WebCore/Modules/websockets/WebSocketChannelInspector.h:
* Source/WebCore/Modules/websockets/WebSocketChannelInspector.cpp:
(WebCore::WebSocketChannelInspector::willSendWebSocketHandshakeRequest const):
(WebCore::WebSocketChannelInspector::didSendWebSocketHandshakeRequest const): Added.
* Source/WebCore/inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::willSendWebSocketHandshakeRequest):
(WebCore::InspectorInstrumentation::didSendWebSocketHandshakeRequest): Added.
* Source/WebCore/inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::willSendWebSocketHandshakeRequestImpl):
(WebCore::InspectorInstrumentation::didSendWebSocketHandshakeRequestImpl): Added.
* Source/WebCore/inspector/LegacyWebSocketInspectorInstrumentation.h:
* Source/WebCore/inspector/LegacyWebSocketInspectorInstrumentation.cpp:
(WebCore::LegacyWebSocketInspectorInstrumentation::willSendWebSocketHandshakeRequest):
(WebCore::LegacyWebSocketInspectorInstrumentation::didSendWebSocketHandshakeRequest): Added.
* Source/WebCore/inspector/agents/InspectorNetworkAgent.h:
* Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:
(WebCore::InspectorNetworkAgent::willSendWebSocketHandshakeRequest):
(WebCore::InspectorNetworkAgent::didSendWebSocketHandshakeRequest): Added.
(WebCore::InspectorNetworkAgent::enable):
Rename the existing `willSendWebSocketHandshakeRequest` to `didSendWebSocketHandshakeRequest` since it actually instrumented after the request was sent.
Add a new `willSendWebSocketHandshakeRequest` that allows Web Inspector to modify the request before it is sent.

* LayoutTests/http/tests/websocket/tests/hybi/inspector/echo-headers_wsh.py: Added.
* LayoutTests/http/tests/websocket/tests/hybi/inspector/set-extra-http-headers.html: Added.
* LayoutTests/http/tests/websocket/tests/hybi/inspector/set-extra-http-headers-expected.txt: Added.

Canonical link: https://commits.webkit.org/315465@main
@webkit-commit-queue

Copy link
Copy Markdown
Collaborator

Committed 315465@main (1e9d5a1): https://commits.webkit.org/315465@main

Reviewed commits have been landed. Closing PR #67097 and removing active labels.

@webkit-commit-queue
webkit-commit-queue merged commit 1e9d5a1 into WebKit:main Jun 18, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jun 18, 2026
@dcrousso
dcrousso deleted the eng/317001 branch June 18, 2026 15:42
dcrousso added a commit to dcrousso/playwright that referenced this pull request Aug 4, 2026
…shake request

`Network.setExtraHTTPHeaders` and an emulated `locale` now reach the `WebSocket` handshake request, but nothing exercised either from the page or from inside a `Worker`

Chromium:
- <https://chromium-review.googlesource.com/c/chromium/src/+/7950740> (Network.setExtraHTTPHeaders should affect WebSocket handshake requests)
- <https://chromium-review.googlesource.com/c/chromium/src/+/8000530> (Network.setExtraHTTPHeaders should affect WebSocket requests in a Worker)

WebKit:
- <WebKit/WebKit#67097> (Web Inspector: Network.setExtraHTTPHeaders does not affect WebSocket)

Chrome Stable and Edge Stable are both still on 150, which predates that Chromium work, so widen the existing guard to `browserMajorVersion < 151` and reuse it on the new cases

Firefox drops the browsing context association when it opens the handshake channel, so the `Worker` cases stay `it.fixme` there until the bundled Firefox picks up <https://phabricator.services.mozilla.com/D310690>
dcrousso added a commit to microsoft/playwright that referenced this pull request Aug 4, 2026
…shake request (#42037)

`Network.setExtraHTTPHeaders` and an emulated `locale` now reach the `WebSocket` handshake request, but nothing exercised either from the page or from inside a `Worker`

Chromium:
- <https://chromium-review.googlesource.com/c/chromium/src/+/7950740> (Network.setExtraHTTPHeaders should affect WebSocket handshake requests)
- <https://chromium-review.googlesource.com/c/chromium/src/+/8000530> (Network.setExtraHTTPHeaders should affect WebSocket requests in a Worker)

WebKit:
- <WebKit/WebKit#67097> (Web Inspector: Network.setExtraHTTPHeaders does not affect WebSocket)

Chrome Stable and Edge Stable are both still on 150, which predates that Chromium work, so widen the existing guard to `browserMajorVersion < 151` and reuse it on the new cases

Firefox drops the browsing context association when it opens the handshake channel, so the `Worker` cases stay `it.fixme` there until the bundled Firefox picks up <https://phabricator.services.mozilla.com/D310690>

fixes <#13919>
fixes <#28948>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Web Inspector Bugs related to the WebKit Web Inspector.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants