Add functional test for header string reuse in HTTP/1.1 (#19588)
This commit is contained in:
parent
487a0f6a5d
commit
f37a750912
|
|
@ -1684,6 +1684,61 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task ReuseRequestHeaderStrings()
|
||||||
|
{
|
||||||
|
var testContext = new TestServiceContext(LoggerFactory);
|
||||||
|
string customHeaderValue = null;
|
||||||
|
string contentTypeHeaderValue = null;
|
||||||
|
|
||||||
|
await using (var server = new TestServer(context =>
|
||||||
|
{
|
||||||
|
customHeaderValue = context.Request.Headers["X-CustomHeader"];
|
||||||
|
contentTypeHeaderValue = context.Request.ContentType;
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}, testContext))
|
||||||
|
{
|
||||||
|
using (var connection = server.CreateConnection())
|
||||||
|
{
|
||||||
|
// First request
|
||||||
|
await connection.Send(
|
||||||
|
"GET / HTTP/1.1",
|
||||||
|
"Host:",
|
||||||
|
"Content-Type: application/test",
|
||||||
|
"X-CustomHeader: customvalue",
|
||||||
|
"",
|
||||||
|
"");
|
||||||
|
await connection.Receive(
|
||||||
|
"HTTP/1.1 200 OK",
|
||||||
|
$"Date: {testContext.DateHeaderValue}",
|
||||||
|
"Content-Length: 0",
|
||||||
|
"",
|
||||||
|
"");
|
||||||
|
|
||||||
|
var initialCustomHeaderValue = customHeaderValue;
|
||||||
|
var initialContentTypeValue = contentTypeHeaderValue;
|
||||||
|
|
||||||
|
// Second request
|
||||||
|
await connection.Send(
|
||||||
|
"GET / HTTP/1.1",
|
||||||
|
"Host:",
|
||||||
|
"Content-Type: application/test",
|
||||||
|
"X-CustomHeader: customvalue",
|
||||||
|
"",
|
||||||
|
"");
|
||||||
|
await connection.Receive(
|
||||||
|
"HTTP/1.1 200 OK",
|
||||||
|
$"Date: {testContext.DateHeaderValue}",
|
||||||
|
"Content-Length: 0",
|
||||||
|
"",
|
||||||
|
"");
|
||||||
|
|
||||||
|
Assert.NotSame(initialCustomHeaderValue, customHeaderValue);
|
||||||
|
Assert.Same(initialContentTypeValue, contentTypeHeaderValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Latin1HeaderValueAcceptedWhenLatin1OptionIsConfigured()
|
public async Task Latin1HeaderValueAcceptedWhenLatin1OptionIsConfigured()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue