Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add trailers test
  • Loading branch information
Tratcher committed Jun 30, 2021
commit ca17fafb296c426203e395fcf55fde107b7f1dcb
Original file line number Diff line number Diff line change
Expand Up @@ -2213,6 +2213,44 @@ await ExpectAsync(Http2FrameType.DATA,
Assert.Equal("200", _decodedHeaders[HeaderNames.Status]);
}

[Fact]
public async Task ResponseTrailers_WithNonAsciiAndCustomEncoder_Works()
{
// TODO: How to correctly modify this per test?
_serviceContext.ServerOptions.ResponseHeaderEncodingSelector = _ => Encoding.UTF8;

await InitializeConnectionAsync(async context =>
{
await context.Response.WriteAsync("Hello World");
context.Response.AppendTrailer("CustomName", "Custom 你好 Value");
});

await StartStreamAsync(1, _browserRequestHeaders, endStream: true);

var headersFrame = await ExpectAsync(Http2FrameType.HEADERS,
withLength: 32,
withFlags: (byte)Http2HeadersFrameFlags.END_HEADERS,
withStreamId: 1);

await ExpectAsync(Http2FrameType.DATA,
withLength: 11,
withFlags: (byte)Http2DataFrameFlags.NONE,
withStreamId: 1);

await ExpectAsync(Http2FrameType.DATA,
withLength: 0,
withFlags: (byte)Http2DataFrameFlags.END_STREAM,
withStreamId: 1);

await StopConnectionAsync(expectedLastStreamId: 1, ignoreNonGoAwayFrames: false);

_hpackDecoder.Decode(headersFrame.PayloadSequence, endHeaders: true, handler: this);

Assert.Equal(2, _decodedHeaders.Count);
Assert.Contains("date", _decodedHeaders.Keys, StringComparer.OrdinalIgnoreCase);
Assert.Equal("200", _decodedHeaders[HeaderNames.Status]);
}

[Fact]
public async Task ResponseTrailers_TooLong_Throws()
{
Expand Down