Skip to content

Commit 1db20af

Browse files
authored
HTTP/2: Ignore additional RST_STREAM frames sent to stream (#32449)
1 parent 9c4c94c commit 1db20af

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/Servers/Kestrel/Core/src/Internal/Http2/Http2Connection.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,8 +717,13 @@ private Task ProcessRstStreamFrameAsync()
717717
// Second reset
718718
if (stream.RstStreamReceived)
719719
{
720-
// Hard abort, do not allow any more frames on this stream.
721-
throw new Http2ConnectionErrorException(CoreStrings.FormatHttp2ErrorStreamAborted(_incomingFrame.Type, stream.StreamId), Http2ErrorCode.STREAM_CLOSED);
720+
// https://tools.ietf.org/html/rfc7540#section-5.1
721+
// If RST_STREAM has already been received then the stream is in a closed state.
722+
// Additional frames (other than PRIORITY) are a stream error.
723+
// The server will usually send a RST_STREAM for a stream error, but RST_STREAM
724+
// shouldn't be sent in response to RST_STREAM to avoid a loop.
725+
// The best course of action here is to do nothing.
726+
return Task.CompletedTask;
722727
}
723728

724729
// No additional inbound header or data frames are allowed for this stream after receiving a reset.

src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3067,7 +3067,7 @@ await WaitForConnectionErrorAsync<Http2ConnectionErrorException>(ignoreNonGoAway
30673067
}
30683068

30693069
[Fact]
3070-
public async Task RST_STREAM_IncompleteRequest_AdditionalResetFrame_ConnectionAborted()
3070+
public async Task RST_STREAM_IncompleteRequest_AdditionalResetFrame_IgnoreAdditionalReset()
30713071
{
30723072
var tcs = new TaskCompletionSource<int>(TaskCreationOptions.RunContinuationsAsynchronously);
30733073

@@ -3085,8 +3085,7 @@ public async Task RST_STREAM_IncompleteRequest_AdditionalResetFrame_ConnectionAb
30853085
await SendRstStreamAsync(1);
30863086
tcs.TrySetResult(0);
30873087

3088-
await WaitForConnectionErrorAsync<Http2ConnectionErrorException>(ignoreNonGoAwayFrames: false, expectedLastStreamId: 1,
3089-
Http2ErrorCode.STREAM_CLOSED, CoreStrings.FormatHttp2ErrorStreamAborted(Http2FrameType.RST_STREAM, 1));
3088+
await StopConnectionAsync(expectedLastStreamId: 1, ignoreNonGoAwayFrames: false);
30903089
}
30913090

30923091
[Fact]

0 commit comments

Comments
 (0)