Skip to content

wasmtime-wasi-http: Only inject Host header in the default HTTP/1 send_request path#13138

Merged
pchickey merged 1 commit into
bytecodealliance:mainfrom
namse:p2-host-header-h1-only
Apr 20, 2026
Merged

wasmtime-wasi-http: Only inject Host header in the default HTTP/1 send_request path#13138
pchickey merged 1 commit into
bytecodealliance:mainfrom
namse:p2-host-header-h1-only

Conversation

@namse

@namse namse commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

Currently, outgoing_handler::handle unconditionally appends a Host header to the hyper::Request before calling WasiHttpView::send_request. This is fine for HTTP/1.1, but embedders that override send_request to dispatch over HTTP/2 (e.g. via hyper_util::client::legacy::Client negotiating h2 through ALPN) end up sending both :authority and a host header on the wire. Per RFC 9113 §8.3.1, clients generating HTTP/2 requests directly should use :authority instead of Host, and strict servers such as Google's GFE reject the stream with RST_STREAM PROTOCOL_ERROR when both appear.

This PR moves the Host insertion out of handle and into default_send_request_handler, which is the only code path in this crate that terminates in hyper::client::conn::http1::handshake. HTTP/1 dispatch preserves the existing behavior, while custom send_request implementations no longer have to strip the header themselves.

@namse namse requested a review from a team as a code owner April 19, 2026 13:35
@pchickey pchickey added this pull request to the merge queue Apr 20, 2026
Merged via the queue into bytecodealliance:main with commit cc84f98 Apr 20, 2026
48 checks passed
@namse namse deleted the p2-host-header-h1-only branch April 21, 2026 00:18
vigoo added a commit to golemcloud/wasmtime that referenced this pull request May 26, 2026
Ports the Golem fork's wasi-http changes from v42.0.1 onto v45.0.0:

- Async bindgen imports for outgoing-handler.handle, future-incoming-response.get,
  future-trailers.get, incoming-body.finish/drop, incoming-response.drop,
  future-incoming-response.drop (matching v42 fork list)
- HostFutureIncomingResponse::Deferred variant + activation logic in get()
  per trigger_deferred_on_ready.md
- HttpConnectionPool extracted into new p2/connection_pool.rs module
  (with HttpConnectionPoolConfig, default_send_request_handler,
  default_send_request_with_pool, pooled_send_request_handler)
- WasiHttpHooks::send_request takes body_completion: Option<BodyCompletionReceiver>
- WasiHttpHooks::connection_pool() override hook
- WasiHttpCtx::connection_pool field
- HostIncomingBody: retain_worker(worker, error_receiver),
  retain_connection_permits, failing(error), take_stream() returns Box,
  worker_error_receiver and connection_permits fields
- HostOutgoingBody: completion_sender + set_completion_sender, finish/abort
  signal completion
- HostOutgoingRequest::body_completion field
- HostIncomingResponse::pooled_connection field + poison_pooled_connection()
- ConnWorkerErrorReceiver / ConnectionPermits types
- DeferredSendFn type
- IncomingResponse extended with worker_error_receiver, connection_permits,
  pooled_connection
- FailingStream stream that always returns LastOperationFailed
- Authority empty/missing rejection in handle()
- Explicit Host header injection in handle() (matching post-v42 fix bytecodealliance#13138)
- hyper-rustls bumped to 0.27 (compatible with rustls 0.23)
- Re-export HttpConnectionPool/HttpConnectionPoolConfig from crate root

Amp-Thread-ID: https://ampcode.com/threads/T-019e177d-4b8a-71ed-8739-f413107ed709
Co-authored-by: Amp <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants