Skip to content

fix(http2): surface client RST_STREAM(NO_ERROR) mid-body as error on server - #4295

Closed
Im-HyeonBin wants to merge 2 commits into
hyperium:masterfrom
Im-HyeonBin:fix/h2-server-rst-no-error
Closed

Im-HyeonBin wants to merge 2 commits into
hyperium:masterfrom
Im-HyeonBin:fix/h2-server-rst-no-error

Conversation

@Im-HyeonBin

@Im-HyeonBin Im-HyeonBin commented Dec 1, 2026 •

Copy link
Copy Markdown

Fixes #4286.

Summary

In Incoming (src/body/incoming.rs), h2::Reason::NO_ERROR was 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 with NO_ERROR before END_STREAM, treating it as clean EOF causes server handlers calling collect() to accept a truncated request body without error.

Changes

  • Pass is_client: bool into Incoming::h2 (true from proto::h2::client, false from proto::h2::server).
  • Only suppress h2::Reason::NO_ERROR as Poll::Ready(None) in poll_data and poll_trailers when is_client is true; on the server side, return Error::new_body(e) / Error::new_h2(e).
  • Add regression test h2_server_rst_stream_no_error_mid_body in tests/server.rs covering both content-length and non-content-length requests.

Verification

  • cargo test --features full --lib body::incoming (including test_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"
    • The description, docs, and comments (words meant for humans) are written by a human, not by an LLM.

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
@seanmonstar seanmonstar closed this Dec 1, 2026
@seanmonstar

Copy link
Copy Markdown
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.

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.

HTTP/2 server: client RST_STREAM(NO_ERROR) mid-body still ends the request body cleanly

2 participants