wingo opened issue #11771:
Consider this test for what the HTTP implementation does with invalid field names. First it tries a field name with a space in it, then it tries
". Both of these are invalid, but the first shows an error onfields.deletewhereas the second does not: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; use wasi::http::types::HeaderError; fn test_invalid_field_name(field: &str) { println!("testing field: {}", field); let fields = Fields::new(); assert!(!fields.has(field)); assert_eq!(fields.delete(field), Err(HeaderError::InvalidSyntax)); } fn test_valid_field_names() { test_invalid_field_name("field with space"); test_invalid_field_name("\""); } fn main() { test_valid_field_names(); }Run it:
$ cargo +nightly build --target=wasm32-wasip2 --release && wasmtime -Wcomponent-model-async -Sp3,http target/wasm32-wasip2/release/field-invalid.wasm Compiling test-wasm32-wasip3 v0.1.0 (/home/wingo/src/wasip3/wasi-testsuite/tests/rust/wasm32-wasip3) Finished `release` profile [optimized] target(s) in 0.35s testing field: field with space testing field: " thread 'main' (1) panicked at src/bin/field-invalid.rs:23:5: assertion `left == right` failed left: Ok(()) right: Err(HeaderError::InvalidSyntax)
wingo added the bug label to Issue #11771.
wingo commented on issue #11771:
Related to https://github.com/WebAssembly/wasi-http/issues/192.
wingo edited issue #11771:
Consider this test for what the HTTP implementation does with invalid field names. First it tries a field name with a space in it, then it tries
". Both of these are invalid, but the first shows an error onfields.deletewhereas the second does not: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; use wasi::http::types::HeaderError; fn test_invalid_field_name(field: &str) { println!("testing field: {}", field); let fields = Fields::new(); assert!(!fields.has(field)); assert_eq!(fields.delete(field), Err(HeaderError::InvalidSyntax)); } fn test_invalid_field_names() { test_invalid_field_name("field with space"); test_invalid_field_name("\""); } fn main() { test_invalid_field_names(); }Run it:
$ cargo +nightly build --target=wasm32-wasip2 --release && wasmtime -Wcomponent-model-async -Sp3,http target/wasm32-wasip2/release/field-invalid.wasm Compiling test-wasm32-wasip3 v0.1.0 (/home/wingo/src/wasip3/wasi-testsuite/tests/rust/wasm32-wasip3) Finished `release` profile [optimized] target(s) in 0.35s testing field: field with space testing field: " thread 'main' (1) panicked at src/bin/field-invalid.rs:23:5: assertion `left == right` failed left: Ok(()) right: Err(HeaderError::InvalidSyntax)
wingo commented on issue #11771:
Also related to https://github.com/WebAssembly/wasi-http/issues/178, could it be that Wasmtime is thinking that
"is valid in a field name?
alexcrichton added the wasi:impl label to Issue #11771.
Last updated: Dec 06 2025 at 07:03 UTC