Add reset stream API - #104
Draft
gjcairo wants to merge 1 commit into
Draft
Conversation
Collaborator
|
Related apple/swift-nio-http3#14 |
aryan-25
approved these changes
Jul 31, 2026
| /// | ||
| /// - Parameter code: The `RST_STREAM` error code to send. | ||
| public consuming func reset(code: HTTP2ErrorCode) { | ||
| // The `HTTP2FramePayloadToHTTPServerCodec` on the stream channel translates this event into an `RST_STREAM` |
Collaborator
There was a problem hiding this comment.
nit:
Suggested change
| // The `HTTP2FramePayloadToHTTPServerCodec` on the stream channel translates this event into an `RST_STREAM` | |
| // The `HTTP2FramePayloadToHTTPServerCodec` on the stream channel translates this event into a `RST_STREAM` |
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.
Until now, a request handler had no way to abort the stream carrying a request.
This PR adds a reset operation to the response side:
ResponseSender.reset(_:): abort before any response head is sent.Writer.reset(_:): abort a response that has already started.Because a reset is inherently protocol-specific, reset hands the handler a protocol-discriminated
NIOHTTPServer.StreamResetto switch over:.http2→ sends an HTTP/2 RST_STREAM with a chosenHTTP2ErrorCode..http3→ sends an HTTP/3 RESET_STREAM with a chosen QUIC application error code..unavailable→ HTTP/1.1, which has no per-stream reset.resetconsumes the sender/writer, so users are prevented from writing anything further once the stream has been reset.An example scenario using
CONNECT: