Fast-path response header connection check
This commit is contained in:
parent
86567e1d93
commit
5eb1466487
|
|
@ -670,14 +670,17 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
|
||||||
var responseHeaders = _frameHeaders.ResponseHeaders;
|
var responseHeaders = _frameHeaders.ResponseHeaders;
|
||||||
responseHeaders.SetReadOnly();
|
responseHeaders.SetReadOnly();
|
||||||
|
|
||||||
|
var hasConnection = responseHeaders.HasConnection;
|
||||||
|
|
||||||
var end = SocketOutput.ProducingStart();
|
var end = SocketOutput.ProducingStart();
|
||||||
if (_keepAlive)
|
if (_keepAlive && hasConnection)
|
||||||
{
|
{
|
||||||
foreach (var connectionValue in responseHeaders.HeaderConnection)
|
foreach (var connectionValue in responseHeaders.HeaderConnection)
|
||||||
{
|
{
|
||||||
if (connectionValue.IndexOf("close", StringComparison.OrdinalIgnoreCase) != -1)
|
if (connectionValue.IndexOf("close", StringComparison.OrdinalIgnoreCase) != -1)
|
||||||
{
|
{
|
||||||
_keepAlive = false;
|
_keepAlive = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -716,11 +719,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_keepAlive && !responseHeaders.HasConnection && _httpVersion != HttpVersionType.Http10)
|
if (!_keepAlive && !hasConnection && _httpVersion != HttpVersionType.Http10)
|
||||||
{
|
{
|
||||||
responseHeaders.SetRawConnection("close", _bytesConnectionClose);
|
responseHeaders.SetRawConnection("close", _bytesConnectionClose);
|
||||||
}
|
}
|
||||||
else if (_keepAlive && !responseHeaders.HasConnection && _httpVersion == HttpVersionType.Http10)
|
else if (_keepAlive && !hasConnection && _httpVersion == HttpVersionType.Http10)
|
||||||
{
|
{
|
||||||
responseHeaders.SetRawConnection("keep-alive", _bytesConnectionKeepAlive);
|
responseHeaders.SetRawConnection("keep-alive", _bytesConnectionKeepAlive);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue