Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions crates/test-programs/src/bin/api_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ impl bindings::exports::wasi::http::incoming_handler::Guest for T {
"append of forbidden header succeeded"
);

assert!(
!req_hdrs.has(&"host".to_owned()),
"forbidden host header present in incoming request"
);

let hdrs = bindings::wasi::http::types::Headers::new();
let resp = bindings::wasi::http::types::OutgoingResponse::new(hdrs);
let body = resp.body().expect("outgoing response");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ fn main() {
Err(HeaderError::Forbidden)
));

assert!(matches!(
hdrs.append(&"Host".to_owned(), &b"example.com".to_vec()),
Err(HeaderError::Forbidden)
));

assert!(matches!(
hdrs.append(
&"custom-forbidden-header".to_owned(),
Expand Down
3 changes: 2 additions & 1 deletion crates/wasi-http/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub trait WasiHttpView: Send {

/// Returns `true` when the header is forbidden according to this [`WasiHttpView`] implementation.
pub(crate) fn is_forbidden_header(view: &mut dyn WasiHttpView, name: &HeaderName) -> bool {
static FORBIDDEN_HEADERS: [HeaderName; 9] = [
static FORBIDDEN_HEADERS: [HeaderName; 10] = [
hyper::header::CONNECTION,
HeaderName::from_static("keep-alive"),
hyper::header::PROXY_AUTHENTICATE,
Expand All @@ -86,6 +86,7 @@ pub(crate) fn is_forbidden_header(view: &mut dyn WasiHttpView, name: &HeaderName
hyper::header::TE,
hyper::header::TRANSFER_ENCODING,
hyper::header::UPGRADE,
hyper::header::HOST,
HeaderName::from_static("http2-settings"),
];

Expand Down