Always set "Connection: close" header for non keep-alive responses

This commit is contained in:
Stephen Halter 2016-08-09 17:35:01 -07:00
parent 8f4cc3003b
commit 5f4e60bf8d
6 changed files with 24 additions and 4 deletions

View File

@ -767,7 +767,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
}
}
if (!_keepAlive && !hasConnection && _httpVersion != Http.HttpVersion.Http10)
if (!_keepAlive && !hasConnection)
{
responseHeaders.SetRawConnection("close", _bytesConnectionClose);
}

View File

@ -75,6 +75,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
"");
await connection.ReceiveEnd(
"HTTP/1.1 200 OK",
"Connection: close",
$"Date: {testContext.DateHeaderValue}",
"",
"Hello World");
@ -111,6 +112,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
"Hello World");
await connection.ReceiveEnd(
"HTTP/1.1 200 OK",
"Connection: close",
$"Date: {testContext.DateHeaderValue}",
"Content-Length: 7",
"",

View File

@ -44,6 +44,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
await connection.SendEnd(sendString);
await connection.ReceiveEnd(
"HTTP/1.1 200 OK",
"Connection: close",
$"Date: {serviceContext.DateHeaderValue}",
"",
"Hello World!");
@ -68,6 +69,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
"Hello World?");
await connection.ReceiveEnd(
"HTTP/1.1 200 OK",
"Connection: close",
$"Date: {serviceContext.DateHeaderValue}",
"",
"Hello World!");

View File

@ -24,6 +24,8 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
using (var connection = server.CreateConnection())
{
await connection.SendEnd(
"GET / HTTP/1.1",
"",
"GET / HTTP/1.0",
"",
"");
@ -31,6 +33,12 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
await connection.ReceiveEnd(
"HTTP/1.1 200 OK",
$"Date: {testContext.DateHeaderValue}",
"Content-Length: 0",
"Server: Kestrel",
"",
"HTTP/1.1 200 OK",
"Connection: close",
$"Date: {testContext.DateHeaderValue}",
"Server: Kestrel",
"",
"");

View File

@ -135,6 +135,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
"Hello World");
await connection.ReceiveEnd(
"HTTP/1.1 200 OK",
"Connection: close",
$"Date: {testContext.DateHeaderValue}",
"",
"Hello World");
@ -259,6 +260,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
"Hello World");
await connection.ReceiveEnd(
"HTTP/1.1 200 OK",
"Connection: close",
$"Date: {testContext.DateHeaderValue}",
"",
"Hello World");
@ -289,6 +291,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
"\r\n");
await connection.ReceiveEnd(
"HTTP/1.1 200 OK",
"Connection: close",
$"Date: {testContext.DateHeaderValue}",
"Content-Length: 7",
"",
@ -322,6 +325,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
"\r\n");
await connection.ReceiveEnd(
"HTTP/1.1 200 OK",
"Connection: close",
$"Date: {testContext.DateHeaderValue}",
"",
"Goodbye");
@ -354,6 +358,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
"Hello World");
await connection.ReceiveEnd(
"HTTP/1.1 200 OK",
"Connection: close",
$"Date: {testContext.DateHeaderValue}",
"Content-Length: 7",
"",
@ -407,6 +412,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
"\r\n");
await connection.ReceiveEnd(
"HTTP/1.1 200 OK",
"Connection: close",
$"Date: {testContext.DateHeaderValue}",
"\r\n");
}
@ -472,6 +478,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
"");
await connection.ReceiveEnd(
"HTTP/1.1 200 OK",
"Connection: close",
$"Date: {testContext.DateHeaderValue}",
"",
"");
@ -1050,6 +1057,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
"");
await connection.ReceiveForcedEnd(
"HTTP/1.1 200 OK",
"Connection: close",
$"Date: {testContext.DateHeaderValue}",
"Content-Length: 11",
"",

View File

@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
using (var connection = server.CreateConnection())
{
await connection.SendEnd(
"GET /%41%CC%8A/A/../B/%41%CC%8A HTTP/1.0",
"GET /%41%CC%8A/A/../B/%41%CC%8A HTTP/1.1",
"",
"");
await connection.ReceiveEnd(
@ -71,7 +71,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
using (var connection = server.CreateConnection())
{
await connection.SendEnd(
$"GET {requestTarget} HTTP/1.0",
$"GET {requestTarget} HTTP/1.1",
"",
"");
await connection.ReceiveEnd(
@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
using (var connection = server.CreateConnection())
{
await connection.SendEnd(
$"GET {requestTarget} HTTP/1.0",
$"GET {requestTarget} HTTP/1.1",
"",
"");
await connection.ReceiveEnd(