Skip to content

Fill in CONNECT pseudo-headers automatically (e.g. from request mode) #1881

@jan-ivar

Description

@jan-ivar

What is the issue with the Fetch Standard?

Fetch allows setting method to "CONNECT", a concept requiring filling in pseudo-headers in H2/H3, which isn't done, so WebTransport has to hand-wave about it:

Set request’s method to "CONNECT", and set the method’s associated pseudo-headers as follows: :protocol to "webtransport", :scheme, :authority, and :path from request’s 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. whatwg/websockets#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 (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

Metadata

Metadata

Assignees

No one assigned

    Labels

    integrationBetter coordination across standards neededtopic: websocketsWebSockets integration

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions