Skip to content

feat: add support for custom fetch headers in requests#84

Open
ruslanti wants to merge 1 commit into
mainfrom
feat/wasi_fetch_with_custom_header
Open

feat: add support for custom fetch headers in requests#84
ruslanti wants to merge 1 commit into
mainfrom
feat/wasi_fetch_with_custom_header

Conversation

@ruslanti

Copy link
Copy Markdown
Collaborator

No description provided.

@ruslanti
ruslanti requested review from godronus and qrdl July 16, 2026 07:35
@ruslanti ruslanti self-assigned this Jul 16, 2026
Copilot AI review requested due to automatic review settings July 16, 2026 07:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support in the simple_fetch WASI HTTP example to optionally forward a caller-provided header to the upstream fetch request.

Changes:

  • Build the upstream request via a mutable Request::Builder and optionally add a header from x-fetch-header.
  • Bump the simple_fetch example crate version to 0.1.1.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
examples/http/wasi/simple_fetch/src/lib.rs Adds parsing of x-fetch-header to inject a caller-provided header into the upstream request builder.
examples/http/wasi/simple_fetch/Cargo.toml Bumps the example crate version to 0.1.1.

Comment on lines +31 to +39
if let Some(fetch_header) = request
.headers()
.get("x-fetch-header")
.and_then(|v| v.to_str().ok())
{
if let Some((key, value)) = fetch_header.split_once(':') {
builder = builder.header(key.trim(), value.trim());
}
}
[package]
name = "simple_fetch"
version = "0.1.0"
version = "0.1.1"
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.

4 participants