Refactored to use the fields from the HttpMethods class
* Reacting to PR comments
This commit is contained in:
parent
310411075f
commit
12adc7de9d
|
|
@ -4,6 +4,7 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
|
||||
|
|
@ -12,16 +13,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
|
|||
{
|
||||
private static readonly Encoding _utf8 = Encoding.UTF8;
|
||||
|
||||
public const string HttpConnectMethod = "CONNECT";
|
||||
public const string HttpDeleteMethod = "DELETE";
|
||||
public const string HttpGetMethod = "GET";
|
||||
public const string HttpHeadMethod = "HEAD";
|
||||
public const string HttpPatchMethod = "PATCH";
|
||||
public const string HttpPostMethod = "POST";
|
||||
public const string HttpPutMethod = "PUT";
|
||||
public const string HttpOptionsMethod = "OPTIONS";
|
||||
public const string HttpTraceMethod = "TRACE";
|
||||
|
||||
public const string Http10Version = "HTTP/1.0";
|
||||
public const string Http11Version = "HTTP/1.1";
|
||||
|
||||
|
|
@ -49,14 +40,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
|
|||
|
||||
static MemoryPoolIteratorExtensions()
|
||||
{
|
||||
_knownMethods[0] = Tuple.Create(_mask4Chars, _httpPutMethodLong, HttpPutMethod);
|
||||
_knownMethods[1] = Tuple.Create(_mask5Chars, _httpPostMethodLong, HttpPostMethod);
|
||||
_knownMethods[2] = Tuple.Create(_mask5Chars, _httpHeadMethodLong, HttpHeadMethod);
|
||||
_knownMethods[3] = Tuple.Create(_mask6Chars, _httpTraceMethodLong, HttpTraceMethod);
|
||||
_knownMethods[4] = Tuple.Create(_mask6Chars, _httpPatchMethodLong, HttpPatchMethod);
|
||||
_knownMethods[5] = Tuple.Create(_mask7Chars, _httpDeleteMethodLong, HttpDeleteMethod);
|
||||
_knownMethods[6] = Tuple.Create(_mask8Chars, _httpConnectMethodLong, HttpConnectMethod);
|
||||
_knownMethods[7] = Tuple.Create(_mask8Chars, _httpOptionsMethodLong, HttpOptionsMethod);
|
||||
_knownMethods[0] = Tuple.Create(_mask4Chars, _httpPutMethodLong, HttpMethods.Put);
|
||||
_knownMethods[1] = Tuple.Create(_mask5Chars, _httpPostMethodLong, HttpMethods.Post);
|
||||
_knownMethods[2] = Tuple.Create(_mask5Chars, _httpHeadMethodLong, HttpMethods.Head);
|
||||
_knownMethods[3] = Tuple.Create(_mask6Chars, _httpTraceMethodLong, HttpMethods.Trace);
|
||||
_knownMethods[4] = Tuple.Create(_mask6Chars, _httpPatchMethodLong, HttpMethods.Patch);
|
||||
_knownMethods[5] = Tuple.Create(_mask7Chars, _httpDeleteMethodLong, HttpMethods.Delete);
|
||||
_knownMethods[6] = Tuple.Create(_mask8Chars, _httpConnectMethodLong, HttpMethods.Connect);
|
||||
_knownMethods[7] = Tuple.Create(_mask8Chars, _httpOptionsMethodLong, HttpMethods.Options);
|
||||
}
|
||||
|
||||
private unsafe static long GetAsciiStringAsLong(string str)
|
||||
|
|
@ -279,7 +270,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
|
|||
|
||||
if ((value & _mask4Chars) == _httpGetMethodLong)
|
||||
{
|
||||
knownMethod = HttpGetMethod;
|
||||
knownMethod = HttpMethods.Get;
|
||||
return true;
|
||||
}
|
||||
foreach (var x in _knownMethods)
|
||||
|
|
|
|||
|
|
@ -432,15 +432,15 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("CONNECT / HTTP/1.1", ' ', true, MemoryPoolIteratorExtensions.HttpConnectMethod)]
|
||||
[InlineData("DELETE / HTTP/1.1", ' ', true, MemoryPoolIteratorExtensions.HttpDeleteMethod)]
|
||||
[InlineData("GET / HTTP/1.1", ' ', true, MemoryPoolIteratorExtensions.HttpGetMethod)]
|
||||
[InlineData("HEAD / HTTP/1.1", ' ', true, MemoryPoolIteratorExtensions.HttpHeadMethod)]
|
||||
[InlineData("PATCH / HTTP/1.1", ' ', true, MemoryPoolIteratorExtensions.HttpPatchMethod)]
|
||||
[InlineData("POST / HTTP/1.1", ' ', true, MemoryPoolIteratorExtensions.HttpPostMethod)]
|
||||
[InlineData("PUT / HTTP/1.1", ' ', true, MemoryPoolIteratorExtensions.HttpPutMethod)]
|
||||
[InlineData("OPTIONS / HTTP/1.1", ' ', true, MemoryPoolIteratorExtensions.HttpOptionsMethod)]
|
||||
[InlineData("TRACE / HTTP/1.1", ' ', true, MemoryPoolIteratorExtensions.HttpTraceMethod)]
|
||||
[InlineData("CONNECT / HTTP/1.1", ' ', true, "CONNECT")]
|
||||
[InlineData("DELETE / HTTP/1.1", ' ', true, "DELETE")]
|
||||
[InlineData("GET / HTTP/1.1", ' ', true, "GET")]
|
||||
[InlineData("HEAD / HTTP/1.1", ' ', true, "HEAD")]
|
||||
[InlineData("PATCH / HTTP/1.1", ' ', true, "PATCH")]
|
||||
[InlineData("POST / HTTP/1.1", ' ', true, "POST")]
|
||||
[InlineData("PUT / HTTP/1.1", ' ', true, "PUT")]
|
||||
[InlineData("OPTIONS / HTTP/1.1", ' ', true, "OPTIONS")]
|
||||
[InlineData("TRACE / HTTP/1.1", ' ', true, "TRACE")]
|
||||
[InlineData("GET/ HTTP/1.1", ' ', false, null)]
|
||||
[InlineData("get / HTTP/1.1", ' ', false, null)]
|
||||
[InlineData("GOT / HTTP/1.1", ' ', false, null)]
|
||||
|
|
|
|||
Loading…
Reference in New Issue