Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.
This repository was archived by the owner on Nov 25, 2025. It is now read-only.

Perhaps be more specific about casing of field-keys #117

Closed

Description

@rylev

HTTP field keys are case insensitive. However, wasi-http doesn't seem to specify that this should be the case when interacting with fields.

For example, fields#get likely should return values no matter the casing of the field-key passed in. This is how wasmtime's implementation currently works, but it doesn't seem specified anywhere that this must be the case. What's more, in wasmtime fields#entries returns tuples of the field-key/field-value pair where the field-key has the original casing. Is this the correct behavior or should hosts perhaps be expected to canonicalize these fields to lowercase instead?

Activity

  1. pchickey commented on Jun 26, 2024

    @pchickey
    Contributor

    Good point. @guybedford what does node do for this behavior?

  2. guybedford commented on Jun 26, 2024

    @guybedford

    Node.js automatically lowercases all header keys by the time they are provided to the user.

  3. lukewagner commented on Jun 28, 2024

    @lukewagner
    Member

    Yes, good point, we need to improve the specified behavior here. I'd suggest the following:

    • Specify that field-name equality (as used by fields.get, fields.set, etc) is case insensitive (as defined by RFC 9110)
    • The fields resource remembers the original case of field names (exactly as passed to set or as came in over the wire), and this remembered-case is what goes out over the wire. This is what the JS Fetch API specifies because it was found necessary in practice for various interop scenarios.
    • Unlike with the JS Fetch API's Headers.get(), which returns always-lowered, and Headers.entries(), which returns always-sorted, specify that WASI HTTP's fields.get and fields.entries returns the original case in the over-the-wire order so that it's possible for content to know exactly what will go out over the wire.
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