Ensure body reads only return 0-length at the end #483
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.
Tests and a slightly broader preventative measure for #479.
The Rust
Read
trait uses a return value ofOk(0)
to indicate a (permanent/temporary) end-of-stream, e.g. end-of-file.We use the same convention for the
fastly_http_body::read
hostcall.The
Body
trait is a little more careful, with a separateis_stream_end
method distinct from the "length of frame" property.However, this means if our
Body
implementations ever yield a zero-length chunk, thefastly_http_body::read
hostcall will look like an end-of-stream to the guest. That's at the root of #479.#480 addresses the observed cause- that the gzip decoder in particular can yield zero-length chunks when the header + body are split. However, it's in principle possible for another (current or future) variant of
Body
to reintroduce the issue.http::Body
stream-style API to thestd::io::Read
-style API. Add aBody::read
method that acts more like theAsyncRead
traits; use it from the hostcalls, instead of puttingBody
internals in those hostcalls.Fixed #479 (to my satisfaction)