Repository navigation
fix(http2): surface client RST_STREAM(NO_ERROR) mid-body as error on server - #4295
Closed
Im-HyeonBin wants to merge 2 commits into
Closed
Im-HyeonBin wants to merge 2 commits into
Im-HyeonBin wants to merge 2 commits into
Conversation
Per RFC 9113 Section 8.1, suppressing RST_STREAM(NO_ERROR) as clean EOF applies to a client reading an early response from a server. On the server side, a client resetting its own request stream with NO_ERROR before END_STREAM means the request body is incomplete and must surface as an error rather than ending cleanly. Track the role (is_client) in Incoming::H2 so NO_ERROR suppression only applies to client response bodies, and add a regression test covering both content-length and streaming request bodies. Fixes hyperium#4286
Member
|
Thanks for the PR. I think this ends up being both more complex and also not fully fixing the issue, so I wrote up #4296 as a replacement. |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #4286.
Summary
In
Incoming(src/body/incoming.rs),h2::Reason::NO_ERRORwas treated as a clean EOF (Poll::Ready(None)) for both client response bodies and server request bodies.Per RFC 9113 Section 8.1,
RST_STREAM(NO_ERROR)as an early-response termination signal applies when a server stops an unwanted request body after sending a complete response (read by the client). When a client resets its own unfinished request stream withNO_ERRORbeforeEND_STREAM, treating it as clean EOF causes server handlers callingcollect()to accept a truncated request body without error.Changes
is_client: boolintoIncoming::h2(truefromproto::h2::client,falsefromproto::h2::server).h2::Reason::NO_ERRORasPoll::Ready(None)inpoll_dataandpoll_trailerswhenis_clientistrue; on the server side, returnError::new_body(e)/Error::new_h2(e).h2_server_rst_stream_no_error_mid_bodyintests/server.rscovering bothcontent-lengthand non-content-lengthrequests.Verification
cargo test --features full --lib body::incoming(includingtest_size_of—size_of::<Incoming>()unchanged)cargo test --features full --test server --test client -- h2_cargo check --no-default-features --features "http2,server"cargo check --no-default-features --features "http2,client"