adamrk opened PR #15027 from adamrk:abk/http-body-peek-bug to bytecodealliance:main:
When a guest passes an http request/response to the host and the body contains a host provided
StreamProducer, we take the fast path of downcasting the stream to the underlyinghttp::Body. But if the guest read from the stream before passing it on, there may be a buffer of data that was read out of theStreamProducer, but not handled by the guest.This change ensures that that buffered data is included when downcasting to an
http::Body. Otherwise it will be silently dropped.Resolves https://github.com/bytecodealliance/wasmtime/issues/15020
adamrk removed the review request for wasmtime-wasi-reviewers from PR #15027.
adamrk requested rvolosatovs for a review on PR #15027.
adamrk requested wasmtime-wasi-reviewers for a review on PR #15027.
adamrk removed the review request for wasmtime-core-reviewers from PR #15027.
adamrk requested wasmtime-core-reviewers for a review on PR #15027.
adamrk requested pchickey for a review on PR #15027.
github-actions[bot] added the label wasmtime:api on PR #15027.
:thumbs_up: rvolosatovs submitted PR review:
LGTM, few minor comments
:speech_balloon: rvolosatovs created PR review comment:
nit; could we use
saturating_add?
:speech_balloon: rvolosatovs created PR review comment:
Could we split this in at least two frames instead to test that the
BodyWithPrefixactually forwards to the wrappedbodycorrectly?In the current test
BodyWithPrefixnever reads anything from the innerbody, because it's read in full byHostBodyStreamProducer.We could also consider adding trailers here
:speech_balloon: rvolosatovs created PR review comment:
What do you think about storing
Bytesdirectly and checking foris_empty()instead ofNone?
:speech_balloon: rvolosatovs created PR review comment:
could
oneshot::channel().0be split into a separate assignment with alet, e.g.let (tx, _) = oneshot::channel()?
:speech_balloon: rvolosatovs created PR review comment:
Could we move this from a comment to a reason with
ignore =? See https://doc.rust-lang.org/reference/attributes/testing.html#the-ignore-attribute
adamrk updated PR #15027.
:memo: adamrk submitted PR review.
:speech_balloon: adamrk created PR review comment:
Yeah I was also thinking we should refactor
run_httpsince that channel is really only used for some of the tests. What do you think about this additionally: https://github.com/bytecodealliance/wasmtime/pull/15041 ?
adamrk requested rvolosatovs for a review on PR #15027.
:thumbs_up: rvolosatovs submitted PR review.
:speech_balloon: rvolosatovs created PR review comment:
This should have used
saturating_addas well I think
:memo: rvolosatovs submitted PR review.
:speech_balloon: rvolosatovs created PR review comment:
Actually, in the highly unlikely edge case of this overflowing saturating add would be wrong, we'd need to use
checked_addand set this toNoneif it did not fit.
I think this is fine as-is.
rvolosatovs added PR #15027 wasi-http: Ensure buffered body reads aren't dropped when guests pass a host-provided body to the merge queue.
:speech_balloon: rvolosatovs edited PR review comment.
:check: rvolosatovs merged PR #15027.
rvolosatovs removed PR #15027 wasi-http: Ensure buffered body reads aren't dropped when guests pass a host-provided body from the merge queue.
Last updated: Oct 31 2026 at 23:03 UTC