Skip to content

WASIp3 http/fields does not preserve case #11770

@wingo

Description

@wingo

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/[email protected];
  }
",
    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])]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect behavior in the current implementation that needs fixingwasi:implIssues pertaining to WASI implementation in Wasmtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions