Stream: git-wasmtime

Topic: wasmtime / issue #11770 WASIp3 http/fields does not prese...


view this post on Zulip Wasmtime GitHub notifications bot (Oct 01 2025 at 09:14):

wingo opened issue #11770:

Consider the spec for wasi:http/fields#copy-all:

    /// Retrieve the full set of names and values in the Fields. Like the
    /// constructor, the list represents each name-value pair.
    ///
    /// The outer list represents each name-value pair in the Fields. Names
    /// which have multiple values are represented by multiple entries in this
    /// list with the same name.
    ///
    /// The names and values are always returned in the original casing and in
    /// the order in which they will be serialized for transport.
    copy-all: func() -> list<tuple<field-name, field-value>>;

However, Wasmtime does not preserve case. If I add a field named "Foo", and then I copy_all, the field name that I get is "foo".

extern crate wit_bindgen;

wit_bindgen::generate!({
    inline: r"
  package test:test;

  world test {
      include wasi:http/imports@0.3.0-rc-2025-09-16;
  }
",
    additional_derives: [PartialEq, Eq, Hash, Clone],
    features:["clocks-timezone"],
    generate_all
});

use wasi::http::types::Fields;

fn test_valid_field_name(field: &str) {
    let fields = Fields::new();
    assert!(!fields.has(field));
    fields.set(field, &[b"val".to_vec()]).unwrap();
    assert_eq!(fields.copy_all(),
               [(field.to_string(), b"val".to_vec())]);
}

fn test_valid_field_names() {
    test_valid_field_name("Foo");
}

fn main() {
    test_valid_field_names();
}

thread 'main' (1) panicked at src/bin/field-capitalization.rs:22:5:
assertion `left == right` failed
  left: [("foo", [118, 97, 108])]
 right: [("Foo", [118, 97, 108])]

view this post on Zulip Wasmtime GitHub notifications bot (Oct 01 2025 at 09:14):

wingo added the bug label to Issue #11770.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 01 2025 at 09:16):

wingo commented on issue #11770:

Related to https://github.com/WebAssembly/wasi-http/issues/182.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 01 2025 at 09:26):

bjorn3 commented on issue #11770:

Wasmtime uses the HeaderMap type from the http crate to store headers. This stores all header names as lower case: https://docs.rs/http/latest/http/header/struct.HeaderName.html#representation

HeaderName represents standard header names using an enum, as such they will not require an allocation for storage. All custom header names are lower cased upon conversion to a HeaderName value. This avoids the overhead of dynamically doing lower case conversion during the hash code computation and the comparison operation.

FWIW HTTP/2 and HTTP/3 always make all headers lower case.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 01 2025 at 14:14):

alexcrichton added the wasi:impl label to Issue #11770.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 01 2025 at 16:59):

pchickey commented on issue #11770:

Various other wasi-http implementations do not / cannot preserve the casing of name fields as well - whatwg fetch normalizes all names to lowercase. In my opinion we need to make a spec change here.


Last updated: Dec 06 2025 at 07:03 UTC