Skip to content

Commit

Permalink
React to new HttpClient header size check #45811 (#45880)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tratcher authored and dougbu committed Feb 15, 2023
1 parent 317a8ca commit 1d4dd6b
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,6 @@ public async Task Settings_MaxFrameSize_Larger_Server(string scheme)

[Theory]
[MemberData(nameof(SupportedSchemes))]
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/45811")]
public async Task Settings_MaxHeaderListSize_Server(string scheme)
{
var oneKbString = new string('a', 1024);
Expand All @@ -1354,26 +1353,27 @@ public async Task Settings_MaxHeaderListSize_Server(string scheme)
{
ConfigureKestrel(webHostBuilder, scheme);
webHostBuilder.ConfigureServices(AddTestLogging)
.Configure(app => app.Run(context => throw new NotImplementedException()));
.Configure(app => app.Run(context => context.Response.WriteAsync("Hello World")));
});
using var host = await hostBuilder.StartAsync().DefaultTimeout();

var url = host.MakeUrl(scheme);

using var client = CreateClient();
// There's no point in waiting for the settings to sync, the client doesn't check the header list size setting.
// https://github.com/dotnet/runtime/blob/48a78bfa13e9c710851690621fc2c0fe1637802c/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs#L467-L494
// Send an initial request to ensure the settings get synced before the real test.
var responseBody = await client.GetStringAsync(url).DefaultTimeout();
Assert.Equal("Hello World", responseBody);

var request = CreateRequestMessage(HttpMethod.Get, url, content: null);
// The default size limit is 32kb.
for (var i = 0; i < 33; i++)
{
request.Headers.Add("header" + i, oneKbString + i);
}
var response = await client.SendAsync(request).DefaultTimeout();
await host.StopAsync().DefaultTimeout();
var ex = await Assert.ThrowsAsync<HttpRequestException>(() => client.SendAsync(request).DefaultTimeout());
Assert.Equal("The HTTP request headers length exceeded the server limit of 32768 bytes.", ex.Message);

Assert.Equal(HttpStatusCode.RequestHeaderFieldsTooLarge, response.StatusCode);
await host.StopAsync().DefaultTimeout();
}

[Theory]
Expand Down

0 comments on commit 1d4dd6b

Please sign in to comment.