This repository was archived by the owner on Sep 8, 2025. It is now read-only.
Move outgoing http body I/O into a store task #229
Merged
alexcrichton merged 2 commits intobytecodealliance:mainfrom Jul 15, 2025
Merged
Move outgoing http body I/O into a store task #229alexcrichton merged 2 commits intobytecodealliance:mainfrom
alexcrichton merged 2 commits intobytecodealliance:mainfrom
Conversation
Don't use a custom future, instead use an `async fn`.
This commit is in preparation for adding `&Accessor` parameters to stream reads/writes. There are a number of fundamental cases that need updating/refactoring throughout wasi-http and this is the first of a small handful that are going to land ahead-of-time. Specifically here the `OutgoingRequestBody` internally contained a future which represented a `StreamReader<u8>` which was polled externally on Hyper's own event loop (e.g. Tokio). This is no longer going to be possible and streams are going to need to stay within the store, so this commit does some refactoring. The major changes here are: * The `OutgoingRequestBody` type is entirely removed. * A new `BodyChannel` type is added to have a `mpsc::Receiver` coming from the store into Hyper. This is a new channel added which represents the link going out of the store. * A new `BodyWithContentLength` combinator was added which handles the content-length-limiting side of the body. Internally when sending an outgoing request the spawned task which takes care of host I/O now also takes care of reading the stream in a loop and forwarding the results along the channel arranged for the outgoing body.
Member
Author
|
cc @rvolosatovs I'm going to go ahead and land this but happy to address any follow-up you run into. |
alexcrichton
added a commit
to alexcrichton/wasip3-prototyping
that referenced
this pull request
Jul 15, 2025
This is similar to bytecodealliance#229 in that it's preparation for adding `Accessor` arguments to future/stream methods. This replaces `Body::Guest::contents` with a `StreamReader<BytesMut>` instead of an in-progress `'static` future. The major consequences of this are: * `Response::into_http` now returns a lump "do this I/O in the store" object instead of separate values and/or generic futures. * Guest-to-guest bodies no longer work if a `body` handle is dropped, notably a tombstone is left because reads cannot be cancelled at this time. * Some test behavior changed because reads are not submitted immediately but are instead deferred to when the body is actually accessed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit is in preparation for adding
&Accessorparameters tostream reads/writes. There are a number of fundamental cases that need
updating/refactoring throughout wasi-http and this is the first of a
small handful that are going to land ahead-of-time.
Specifically here the
OutgoingRequestBodyinternally contained afuture which represented a
StreamReader<u8>which was polledexternally on Hyper's own event loop (e.g. Tokio). This is no longer
going to be possible and streams are going to need to stay within the
store, so this commit does some refactoring.
The major changes here are:
OutgoingRequestBodytype is entirely removed.BodyChanneltype is added to have ampsc::Receivercomingfrom the store into Hyper. This is a new channel added which
represents the link going out of the store.
BodyWithContentLengthcombinator was added which handles thecontent-length-limiting side of the body.
Internally when sending an outgoing request the spawned task which takes
care of host I/O now also takes care of reading the stream in a loop and
forwarding the results along the channel arranged for the outgoing body.