Merge branch 'benaadams/enum-rather-than-string' into dev
This commit is contained in:
commit
3a67cb9df5
|
|
@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
private bool _autoChunk;
|
||||
protected Exception _applicationException;
|
||||
|
||||
private HttpVersionType _httpVersion;
|
||||
protected HttpVersion _httpVersion;
|
||||
|
||||
private readonly string _pathBase;
|
||||
|
||||
|
|
@ -89,11 +89,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
{
|
||||
get
|
||||
{
|
||||
if (_httpVersion == HttpVersionType.Http11)
|
||||
if (_httpVersion == Http.HttpVersion.Http11)
|
||||
{
|
||||
return "HTTP/1.1";
|
||||
}
|
||||
if (_httpVersion == HttpVersionType.Http10)
|
||||
if (_httpVersion == Http.HttpVersion.Http10)
|
||||
{
|
||||
return "HTTP/1.0";
|
||||
}
|
||||
|
|
@ -104,15 +104,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
{
|
||||
if (value == "HTTP/1.1")
|
||||
{
|
||||
_httpVersion = HttpVersionType.Http11;
|
||||
_httpVersion = Http.HttpVersion.Http11;
|
||||
}
|
||||
else if (value == "HTTP/1.0")
|
||||
{
|
||||
_httpVersion = HttpVersionType.Http10;
|
||||
_httpVersion = Http.HttpVersion.Http10;
|
||||
}
|
||||
else
|
||||
{
|
||||
_httpVersion = HttpVersionType.Unset;
|
||||
_httpVersion = Http.HttpVersion.Unset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -290,7 +290,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
PathBase = null;
|
||||
Path = null;
|
||||
QueryString = null;
|
||||
_httpVersion = HttpVersionType.Unset;
|
||||
_httpVersion = Http.HttpVersion.Unset;
|
||||
StatusCode = 200;
|
||||
ReasonPhrase = null;
|
||||
|
||||
|
|
@ -547,7 +547,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
}
|
||||
|
||||
StringValues expect;
|
||||
if (_httpVersion == HttpVersionType.Http11 &&
|
||||
if (_httpVersion == Http.HttpVersion.Http11 &&
|
||||
RequestHeaders.TryGetValue("Expect", out expect) &&
|
||||
(expect.FirstOrDefault() ?? "").Equals("100-continue", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
|
|
@ -749,7 +749,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
//
|
||||
// A server MUST NOT send a response containing Transfer-Encoding unless the corresponding
|
||||
// request indicates HTTP/1.1 (or later).
|
||||
if (_httpVersion == HttpVersionType.Http11)
|
||||
if (_httpVersion == Http.HttpVersion.Http11)
|
||||
{
|
||||
_autoChunk = true;
|
||||
responseHeaders.SetRawTransferEncoding("chunked", _bytesTransferEncodingChunked);
|
||||
|
|
@ -761,11 +761,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
}
|
||||
}
|
||||
|
||||
if (!_keepAlive && !hasConnection && _httpVersion != HttpVersionType.Http10)
|
||||
if (!_keepAlive && !hasConnection && _httpVersion != Http.HttpVersion.Http10)
|
||||
{
|
||||
responseHeaders.SetRawConnection("close", _bytesConnectionClose);
|
||||
}
|
||||
else if (_keepAlive && !hasConnection && _httpVersion == HttpVersionType.Http10)
|
||||
else if (_keepAlive && !hasConnection && _httpVersion == Http.HttpVersion.Http10)
|
||||
{
|
||||
responseHeaders.SetRawConnection("keep-alive", _bytesConnectionKeepAlive);
|
||||
}
|
||||
|
|
@ -1235,13 +1235,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
Log.ApplicationError(ConnectionId, ex);
|
||||
}
|
||||
|
||||
private enum HttpVersionType
|
||||
{
|
||||
Unset = -1,
|
||||
Http10 = 0,
|
||||
Http11 = 1
|
||||
}
|
||||
|
||||
protected enum RequestLineStatus
|
||||
{
|
||||
Empty,
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
|
||||
if (!_requestProcessingStopping)
|
||||
{
|
||||
var messageBody = MessageBody.For(HttpVersion, FrameRequestHeaders, this);
|
||||
var messageBody = MessageBody.For(_httpVersion, FrameRequestHeaders, this);
|
||||
_keepAlive = messageBody.RequestKeepAlive;
|
||||
|
||||
InitializeStreams(messageBody);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
||||
{
|
||||
public enum HttpVersion
|
||||
{
|
||||
Unset = -1,
|
||||
Http10 = 0,
|
||||
Http11 = 1
|
||||
}
|
||||
}
|
||||
|
|
@ -97,13 +97,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
public abstract ValueTask<int> ReadAsyncImplementation(ArraySegment<byte> buffer, CancellationToken cancellationToken);
|
||||
|
||||
public static MessageBody For(
|
||||
string httpVersion,
|
||||
HttpVersion httpVersion,
|
||||
FrameRequestHeaders headers,
|
||||
Frame context)
|
||||
{
|
||||
// see also http://tools.ietf.org/html/rfc2616#section-4.4
|
||||
|
||||
var keepAlive = httpVersion != "HTTP/1.0";
|
||||
var keepAlive = httpVersion != HttpVersion.Http10;
|
||||
|
||||
var connection = headers.HeaderConnection.ToString();
|
||||
if (connection.Length > 0)
|
||||
|
|
|
|||
|
|
@ -502,7 +502,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
var frame = new Frame<object>(application: null, context: connectionContext);
|
||||
frame.InitializeHeaders();
|
||||
|
||||
var messageBody = MessageBody.For("HTTP/1.1", (FrameRequestHeaders)frame.RequestHeaders, frame);
|
||||
var messageBody = MessageBody.For(HttpVersion.Http11, (FrameRequestHeaders)frame.RequestHeaders, frame);
|
||||
frame.InitializeStreams(messageBody);
|
||||
|
||||
var originalRequestBody = frame.RequestBody;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
{
|
||||
using (var input = new TestInput())
|
||||
{
|
||||
var body = MessageBody.For("HTTP/1.0", new FrameRequestHeaders(), input.FrameContext);
|
||||
var body = MessageBody.For(HttpVersion.Http10, new FrameRequestHeaders(), input.FrameContext);
|
||||
var stream = new FrameRequestStream();
|
||||
stream.StartAcceptingReads(body);
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
{
|
||||
using (var input = new TestInput())
|
||||
{
|
||||
var body = MessageBody.For("HTTP/1.0", new FrameRequestHeaders(), input.FrameContext);
|
||||
var body = MessageBody.For(HttpVersion.Http10, new FrameRequestHeaders(), input.FrameContext);
|
||||
var stream = new FrameRequestStream();
|
||||
stream.StartAcceptingReads(body);
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
{
|
||||
using (var input = new TestInput())
|
||||
{
|
||||
var body = MessageBody.For("HTTP/1.0", new FrameRequestHeaders(), input.FrameContext);
|
||||
var body = MessageBody.For(HttpVersion.Http10, new FrameRequestHeaders(), input.FrameContext);
|
||||
var stream = new FrameRequestStream();
|
||||
stream.StartAcceptingReads(body);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue