Skip to content

Commit cc84f98

Browse files
authored
wasmtime-wasi-http: Only inject Host header in the default HTTP/1 send_request path (bytecodealliance#13138)
1 parent e5f572a commit cc84f98

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

crates/wasi-http/src/p2/http_impl.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ impl outgoing_handler::Host for WasiHttpCtxView<'_> {
6464

6565
let authority = req.authority.unwrap_or_else(String::new);
6666

67-
builder = builder.header(hyper::header::HOST, &authority);
68-
6967
let mut uri = http::Uri::builder()
7068
.scheme(scheme)
7169
.authority(authority.clone());

crates/wasi-http/src/p2/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,14 @@ pub async fn default_send_request_handler(
582582
use tokio::net::TcpStream;
583583
use tokio::time::timeout;
584584

585+
if !request.headers().contains_key(hyper::header::HOST) {
586+
if let Some(authority) = request.uri().authority() {
587+
if let Ok(value) = hyper::header::HeaderValue::from_str(authority.as_str()) {
588+
request.headers_mut().insert(hyper::header::HOST, value);
589+
}
590+
}
591+
}
592+
585593
let authority = if let Some(authority) = request.uri().authority() {
586594
if authority.port().is_some() {
587595
authority.to_string()

0 commit comments

Comments
 (0)