Skip to content

Commit 01cae01

Browse files
committed
move the nginx HTTP2 bug workaround
We remove the `host` header from the request if present because (some versions of?) nginx have a known bug such that they can't handle `host` headers in HTTP/2 requests. However, the request interceptor, if present, may have its own opinions about whether a `host` header should be set, and if it insists on setting one we should honor that. So I've moved the workaround to run _before_ the interceptor is run. Signed-off-by: Joel Dice <[email protected]>
1 parent 4c36823 commit 01cae01

File tree

1 file changed

+5
-5
lines changed
  • crates/factor-outbound-http/src

1 file changed

+5
-5
lines changed

crates/factor-outbound-http/src/wasi.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,10 @@ async fn send_request_impl(
425425
*request.uri_mut() = origin.into_uri(path_and_query);
426426
}
427427

428+
// Some servers (looking at you nginx) don't like a host header even though
429+
// http/2 allows it: https://github.com/hyperium/hyper/issues/3298
430+
request.headers_mut().remove(HOST);
431+
428432
if let Some(interceptor) = request_interceptor {
429433
let intercept_request = std::mem::take(&mut request).into();
430434
match interceptor.intercept(intercept_request).await? {
@@ -459,7 +463,7 @@ async fn send_request_impl(
459463
}
460464

461465
async fn send_request_handler(
462-
mut request: http::Request<HyperOutgoingBody>,
466+
request: http::Request<HyperOutgoingBody>,
463467
wasmtime_wasi_http::types::OutgoingRequestConfig {
464468
use_tls,
465469
connect_timeout,
@@ -470,10 +474,6 @@ async fn send_request_handler(
470474
blocked_networks: BlockedNetworks,
471475
http_clients: HttpClients,
472476
) -> Result<wasmtime_wasi_http::types::IncomingResponse, ErrorCode> {
473-
// Some servers (looking at you nginx) don't like a host header even though
474-
// http/2 allows it: https://github.com/hyperium/hyper/issues/3298
475-
request.headers_mut().remove(HOST);
476-
477477
let resp = CONNECT_OPTIONS.scope(
478478
ConnectOptions {
479479
blocked_networks,

0 commit comments

Comments
 (0)