Skip to content

feat(http2): tell a reset upgraded stream from a half-close - #4255

Open
robertream wants to merge 1 commit into
hyperium:masterfrom
robertream:http2-upgrade-reset-is-error
Open

robertream wants to merge 1 commit into
hyperium:masterfrom
robertream:http2-upgrade-reset-is-error

Conversation

@robertream

Copy link
Copy Markdown

An upgraded HTTP/2 stream is a CONNECT stream, and RST_STREAM is the only way its peer can end one abruptly. Every reset currently reads as an end of stream, so an application cannot tell an abandoned session from a peer that finished.

I need this for a WebTransport over HTTP/2 implementation, where the session is the CONNECT stream itself: a reset means the peer abandoned it, and reading that as a clean close reports a signal the peer never sent.

Opt-in, and the default is unchanged. With the flag off the match arms resolve exactly as before, which keeps the CANCEL-reads-as-close behaviour RFC 8441 relies on. Two tests cover both settings, and the flag is the only difference between them.

This needs nothing new from h2, only Reason::NO_ERROR and Reason::CANCEL, so it stands alone from hyperium/h2#993.

An `Upgraded` stream over HTTP/2 is a CONNECT stream, and `RST_STREAM` is the
only way its peer can end one abruptly. Every reset read as an end of stream,
so an application could not tell an abandoned session from a peer that had
finished. Nothing else on the stream carries the distinction: the write half
reports the same error a poll later for a clean half-close as for a reset.

`Builder::upgrade_reset_is_error` opts in to reading any reset but `NO_ERROR`
as `ConnectionReset`, on both ends. Off by default, because reading `CANCEL`
as a close is what RFC 8441 relies on, where a reset is the connection going
away under a protocol that signals its own close in-band. A protocol whose
session is the CONNECT stream itself needs the opposite.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013CWmskbkrYMCKcuYaufajw

This branch has not been deployed

No deployments
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.

1 participant