Skip to content

wasip3::http_compat::http_into_wasi_request should normalize Host -> set-authority #162

Closed

Description

@lann

HTTP specs have two ways to represent the "authority" (aka host) for a request: the Host header and the :authority "pseudo-header" (encoded in a protocol-dependent way): https://www.rfc-editor.org/rfc/rfc9110.html#name-host-and-authority

  • HTTP/1.1 requires Host
  • HTTP/{2,3} permits Host (if a request has Host and :authority they must match)
  • The Web Fetch API forbids Host on requests.

wasmtime-wasi-http currently follows fetch; Host is forbidden and any authority must be set with request.set-authority.

Some existing Rust code sets Host unconditionally instead of using Request::uri -> authority. This repo's wasip3::http_compat::http_into_wasi_request should make this pattern compatible with wasmtime-wasi-http by normalizing to set-authority:

  1. If authority and Host are both present, validate that they are identical. See https://www.rfc-editor.org/info/rfc9113/#name-request-pseudo-header-field for what "identical" means.
  2. If Host is present and authority is not, move Host to authority (request.set-authority)
  3. If Host is (still) present, remove it

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions