bytecodealliance / bytecodealliance/wasmtime
WASIp3 http/fields does not preserve case
- Dominant language
- Rust
- Stars
- 18.6k
- Forks
- 1.8k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 126
Description
Consider the spec for [wasi:http/fields#copy-all](https://github.com/WebAssembly/wasi-http/blob/main/wit-0.3.0-draft/types.wit#L210):
```
/// 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>;
```
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"`.
```rust
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])]
```
Contributor guide
Assessment
This issue has not been assessed yet.