[whatwg/fetch] Fill in CONNECT pseudo-headers automatically (e.g. from request mode) (Issue #1881)

jan-ivar created an issue (whatwg/fetch#1881)

### What is the issue with the Fetch Standard?

Fetch allows setting [method](https://fetch.spec.whatwg.org/#concept-request-method) to "CONNECT", an H2/H3 concept requiring filling in pseudo-headers, which is not done.

Right now, WebTransport has to [hand-wave](https://pr-preview.s3.amazonaws.com/jan-ivar/webtransport/pull/701.html#pseudo-headers) about it:
> Set request’s [method](https://fetch.spec.whatwg.org/#concept-request-method) to "CONNECT", and set the method’s associated pseudo-headers as follows: `:protocol` to "`webtransport`", `:scheme`, `:authority`, and `:path` from request’s [URL](https://fetch.spec.whatwg.org/#concept-request-url).

WT can do so ahead of fetch because H2/H3 is a requirement, but other protocols like WebSocket use extended CONNECT for H2/H3 as well but also has to work with H1.1. https://github.com/whatwg/websockets/issues/70

Pseudo-headers are protocol-specific and probably shouldn't be exposed to JS `Request` as regular headers.

One option might be a new `connect-protocol` internal slot on request. But we already have [mode](https://fetch.spec.whatwg.org/#concept-request-mode) (which already drives the Origin rule), so HTTP-network fetch might already have all the information it needs to fill in these fields correctly once it knows what kind of connection it got. Something like:

- If _request_’s method is "CONNECT", _request_’s mode is "webtransport" or "websocket", and _connection_ is using HTTP/2 or HTTP/3, then
  - Wait for SETTINGS from the server
  - If SETTINGS_ENABLE_CONNECT_PROTOCOL is not "1", return failure
  - Encode the request as extended CONNECT and include pseudo-headers:
     :method = CONNECT, :protocol = request’s mode, and :scheme, :authority, :path from request’s URL
  - Do not send Connection/Upgrade fields


-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/1881
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/fetch/issues/1881@github.com>

Received on Friday, 21 November 2025 16:50:20 UTC