Skip to content

wasi-http: Clean up run_http test helper - #15041

Merged
rvolosatovs merged 2 commits into
bytecodealliance:mainfrom
adamrk:abk/cleanup-run_http-test-helper
Oct 30, 2026
Merged

rvolosatovs merged 2 commits into
bytecodealliance:mainfrom
adamrk:abk/cleanup-run_http-test-helper

Conversation

@adamrk

@adamrk adamrk commented Oct 28, 2026

Copy link
Copy Markdown
Member

The run_http test helper currently takes a channel and sends the uncollected http request down that channel for the caller to see. But only a few tests actually use that and it can otherwise be difficult because the request body many never actually be read and a guest program can be left hanging if it awaits that.

This change hopefully makes run_http more intuitive by not taking the channel and in general reading the full request body. The new version run_http_get_forwarded_request can be used if the caller needs to see how the request was passed along and the new endpoint p3-test-immediate-response can be used when the test needs a response to be sent without the body being read.

Comment thread crates/wasi-http/tests/all/p3/mod.rs Outdated

/// Like [`run_http`], but sends the request forwarded by the guest to one of
/// the `p3-test*` endpoints on `request_tx`.
async fn run_http_get_forwarded_request<E: Into<Error> + 'static>(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could this name be shorter?

Maybe run_http_forwarded or something like that?

// Respond immediately, collecting the request body in the
// background after the response is returned.
let request_tx = self.request_tx.take();
tokio::spawn(collect_request(request, request_tx));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should we check/report errors here? Perhaps we should send a result over request_tx rather than just the collected request?

The `run_http` test helper currently takes a channel and sends the
uncollected http request down that channel for the caller to see. But
only a few tests actually use that and it can otherwise be difficult
because the request body many never actually be read and a guest program
can be left hanging if it awaits that.

This change hopefully makes `run_http` more intuitive by not taking the
channel and in general reading the full request body. The new version
`run_http_get_forwarded_request` can be used if the caller needs to see
how the request was passed along and the new endpoint
`p3-test-immediate-response` can be used when the test needs a response
to be sent without the body being read.
@adamrk
adamrk force-pushed the abk/cleanup-run_http-test-helper branch from 4ecbd99 to 48aeac7 Compare October 29, 2026 19:17
@adamrk
adamrk requested a review from rvolosatovs October 29, 2026 19:18
@rvolosatovs
rvolosatovs added this pull request to the merge queue Oct 29, 2026
Merged via the queue into bytecodealliance:main with commit 1818ef7 Oct 30, 2026
53 checks passed
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