-
Notifications
You must be signed in to change notification settings - Fork 10.4k
34411 HTTP/2 and HTTP/3: Response trailers collection not reset #37627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -328,6 +328,74 @@ await ExpectAsync(Http2FrameType.HEADERS, | |
await StopConnectionAsync(expectedLastStreamId: 3, ignoreNonGoAwayFrames: false); | ||
} | ||
|
||
[Fact] | ||
public async Task CustomResponseTrailersCollection_MultipleStreams_Reset() | ||
{ | ||
IEnumerable<KeyValuePair<string, string>> requestHeaders = new[] | ||
{ | ||
new KeyValuePair<string, string>(HeaderNames.Method, "GET"), | ||
new KeyValuePair<string, string>(HeaderNames.Path, "/hello"), | ||
new KeyValuePair<string, string>(HeaderNames.Scheme, "http"), | ||
new KeyValuePair<string, string>(HeaderNames.Authority, "localhost:80"), | ||
new KeyValuePair<string, string>(HeaderNames.ContentType, "application/json") | ||
}; | ||
|
||
IHeaderDictionary trailersFirst = null; | ||
IHeaderDictionary trailersSecond = null; | ||
var requestCount = 0; | ||
await InitializeConnectionAsync(context => | ||
{ | ||
requestCount++; | ||
|
||
var trailersFeature = context.Features.Get<IHttpResponseTrailersFeature>(); | ||
if (requestCount == 1) | ||
{ | ||
trailersFirst = new ResponseTrailersWrapper(trailersFeature.Trailers); | ||
trailersFeature.Trailers = trailersFirst; | ||
} | ||
else | ||
{ | ||
trailersSecond = trailersFeature.Trailers; | ||
} | ||
return Task.CompletedTask; | ||
}); | ||
|
||
await StartStreamAsync(1, requestHeaders, endStream: true); | ||
|
||
var trailersFrame = await ExpectAsync(Http2FrameType.HEADERS, | ||
withLength: 36, | ||
withFlags: (byte)(Http2HeadersFrameFlags.END_HEADERS | Http2HeadersFrameFlags.END_STREAM), | ||
withStreamId: 1); | ||
|
||
// Ping will trigger the stream to be returned to the pool so we can assert it | ||
await SendPingAsync(Http2PingFrameFlags.NONE); | ||
await ExpectAsync(Http2FrameType.PING, | ||
withLength: 8, | ||
withFlags: (byte)Http2PingFrameFlags.ACK, | ||
withStreamId: 0); | ||
await SendPingAsync(Http2PingFrameFlags.NONE); | ||
await ExpectAsync(Http2FrameType.PING, | ||
withLength: 8, | ||
withFlags: (byte)Http2PingFrameFlags.ACK, | ||
withStreamId: 0); | ||
|
||
// Stream has been returned to the pool | ||
Assert.Equal(1, _connection.StreamPool.Count); | ||
|
||
await StartStreamAsync(3, requestHeaders, endStream: true); | ||
|
||
trailersFrame = await ExpectAsync(Http2FrameType.HEADERS, | ||
withLength: 6, | ||
withFlags: (byte)(Http2HeadersFrameFlags.END_HEADERS | Http2HeadersFrameFlags.END_STREAM), | ||
withStreamId: 3); | ||
|
||
Assert.NotNull(trailersFirst); | ||
Assert.NotNull(trailersSecond); | ||
Assert.NotSame(trailersFirst, trailersSecond); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this test be merged with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I can merge the two. Not sure what you mean by the HTTP3 part though. |
||
|
||
await StopConnectionAsync(expectedLastStreamId: 3, ignoreNonGoAwayFrames: false); | ||
} | ||
|
||
[Fact] | ||
public async Task StreamPool_SingleStream_ReturnedToPool() | ||
{ | ||
|
Uh oh!
There was an error while loading. Please reload this page.