177 references to HttpMethod
InMemory.FunctionalTests (23)
RequestTargetProcessingTests.cs (4)
93[InlineData(HttpMethod.Options, "*")] 94[InlineData(HttpMethod.Connect, "host")] 95public async Task NonPathRequestTargetSetInRawTarget(HttpMethod method, string requestTarget) 111var host = method == HttpMethod.Connect
ResponseTests.cs (17)
605var methods = new HttpMethod[] { 606HttpMethod.Connect, 607HttpMethod.Delete, 608HttpMethod.Get, 609HttpMethod.Head, 610HttpMethod.Options, 611HttpMethod.Patch, 612HttpMethod.Post, 613HttpMethod.Put, 614HttpMethod.Trace 619foreach (var method in methods) 628public async Task AttemptingToWriteNonzeroContentLengthFailsFor1xxAnd204Responses(int statusCode, HttpMethod method) 633public async Task AttemptingToWriteZeroContentLengthFor1xxAnd204Responses_ContentLengthRemoved(int statusCode, HttpMethod method) 648=> await AttemptingToWriteNonzeroContentLengthFails(statusCode, HttpMethod.Connect).ConfigureAwait(true); 662=> await AttemptingToWriteZeroContentLength_ContentLengthRemoved(statusCode, HttpMethod.Connect).ConfigureAwait(true); 664private async Task AttemptingToWriteNonzeroContentLengthFails(int statusCode, HttpMethod method) 700private async Task AttemptingToWriteZeroContentLength_ContentLengthRemoved(int statusCode, HttpMethod method)
src\Servers\Kestrel\shared\test\HttpParsingData.cs (2)
363data.Add($"{method} * HTTP/1.1\r\n", (int)HttpMethod.Options); 368data.Add($"{method} www.example.com:80 HTTP/1.1\r\n", (int)HttpMethod.Connect);
Microsoft.AspNetCore.Server.Kestrel.Core (87)
BadHttpRequestException.cs (1)
20internal BadHttpRequestException(string message, int statusCode, RequestRejectionReason reason, HttpMethod? requiredMethod)
Internal\Http\Http1Connection.cs (6)
284var method = versionAndMethod.Method; 310if (method == HttpMethod.Custom) 437private void OnAuthorityFormTarget(HttpMethod method, Span<byte> target) 450if (method != HttpMethod.Connect) 488private void OnAsteriskFormTarget(HttpMethod method) 494if (method != HttpMethod.Options)
Internal\Http\Http1MessageBody.cs (2)
203if (httpVersion == HttpVersion.Http10 && (context.Method == HttpMethod.Post || context.Method == HttpMethod.Put))
Internal\Http\HttpParser.cs (2)
76var method = requestLine.GetKnownMethod(out var methodEnd); 77if (method == HttpMethod.Custom)
Internal\Http\HttpProtocol.cs (9)
142public HttpMethod Method { get; set; } 354Method = HttpMethod.None; 906if (Method != HttpMethod.Head && 1085if (Method == HttpMethod.Head && _responseBytesWritten > 0) 1106if (Method == HttpMethod.Head && _responseBytesWritten > 0) 1265else if (Method == HttpMethod.Connect && Is2xxCode(StatusCode)) 1281return Method != HttpMethod.Head && 1291Method != HttpMethod.Head && 1363if (Method != HttpMethod.Head)
Internal\Http\IHttpRequestLineHandler.cs (3)
36public HttpVersionAndMethod(HttpMethod method, int methodEnd) 55public HttpMethod Method => (HttpMethod)(byte)(_versionAndMethod >> 8);
Internal\Http2\Http2Stream.cs (7)
238if (Method == HttpMethod.None && !TryValidateMethod()) 248if (Method == HttpMethod.Connect) 312if (Method == HttpMethod.Options && path.Length == 1 && path[0] == '*') 342if (Method == HttpMethod.None) 348if (Method == HttpMethod.Custom) 689Method = HttpMethod.Get; 694Method = HttpMethod.Post;
Internal\Http3\Http3Stream.cs (7)
22using HttpMethod = Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpMethod; 247Method = HttpMethod.Get; 252Method = HttpMethod.Post; 991if (Method == HttpMethod.Connect && HttpRequestHeaders.HeaderProtocol.Count == 0) 1034if (Method == HttpMethod.Options && path.Length == 1 && path[0] == '*') 1064if (Method == HttpMethod.None) 1070if (Method == HttpMethod.Custom)
Internal\Infrastructure\HttpUtilities.cs (28)
34private static void SetKnownMethod(ulong mask, ulong knownMethodUlong, HttpMethod knownMethod, int length) 36_knownMethods[GetKnownMethodIndex(knownMethodUlong)] = new Tuple<ulong, ulong, HttpMethod, int>(mask, knownMethodUlong, knownMethod, length); 43var invalidHttpMethod = new Tuple<ulong, ulong, HttpMethod, int>(_mask8Chars, 0ul, HttpMethod.Custom, 0); 191public static bool GetKnownMethod(this ReadOnlySpan<byte> span, out HttpMethod method, out int length) 194return method != HttpMethod.Custom; 198public static HttpMethod GetKnownMethod(this ReadOnlySpan<byte> span, out int methodLength) 206return HttpMethod.Get; 226return HttpMethod.Custom; 236/// <returns><see cref="HttpMethod"/></returns> 237public static HttpMethod GetKnownMethod(string? value) 258return HttpMethod.None; 277return HttpMethod.Custom; 319static ReadOnlySpan<HttpMethod> Methods() => 321HttpMethod.None, 322HttpMethod.None, 323HttpMethod.None, 324HttpMethod.Get, 325HttpMethod.Head, 326HttpMethod.Trace, 327HttpMethod.Delete, 328HttpMethod.Options, 329HttpMethod.Put, 330HttpMethod.Post, 331HttpMethod.Patch, 332HttpMethod.None, 333HttpMethod.Connect 454public static string? MethodToString(HttpMethod method)
Internal\Infrastructure\HttpUtilities.Generated.cs (19)
35private static readonly Tuple<ulong, ulong, HttpMethod, int>[] _knownMethods = 36new Tuple<ulong, ulong, HttpMethod, int>[17]; 42SetKnownMethod(_mask4Chars, _httpPutMethodLong, HttpMethod.Put, 3); 43SetKnownMethod(_mask5Chars, _httpHeadMethodLong, HttpMethod.Head, 4); 44SetKnownMethod(_mask5Chars, _httpPostMethodLong, HttpMethod.Post, 4); 45SetKnownMethod(_mask6Chars, _httpPatchMethodLong, HttpMethod.Patch, 5); 46SetKnownMethod(_mask6Chars, _httpTraceMethodLong, HttpMethod.Trace, 5); 47SetKnownMethod(_mask7Chars, _httpDeleteMethodLong, HttpMethod.Delete, 6); 48SetKnownMethod(_mask8Chars, _httpConnectMethodLong, HttpMethod.Connect, 7); 49SetKnownMethod(_mask8Chars, _httpOptionsMethodLong, HttpMethod.Options, 7); 51_methodNames[(byte)HttpMethod.Connect] = HttpMethods.Connect; 52_methodNames[(byte)HttpMethod.Delete] = HttpMethods.Delete; 53_methodNames[(byte)HttpMethod.Get] = HttpMethods.Get; 54_methodNames[(byte)HttpMethod.Head] = HttpMethods.Head; 55_methodNames[(byte)HttpMethod.Options] = HttpMethods.Options; 56_methodNames[(byte)HttpMethod.Patch] = HttpMethods.Patch; 57_methodNames[(byte)HttpMethod.Post] = HttpMethods.Post; 58_methodNames[(byte)HttpMethod.Put] = HttpMethods.Put; 59_methodNames[(byte)HttpMethod.Trace] = HttpMethods.Trace;
KestrelBadHttpRequestException.cs (3)
21internal static void Throw(RequestRejectionReason reason, HttpMethod method) 74ex = new BadHttpRequestException(CoreStrings.BadRequest_MethodNotAllowed, StatusCodes.Status405MethodNotAllowed, reason, HttpMethod.Options); 77ex = new BadHttpRequestException(CoreStrings.BadRequest_MethodNotAllowed, StatusCodes.Status405MethodNotAllowed, reason, HttpMethod.Connect);
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (62)
Http1\Http1ConnectionTests.cs (5)
552var allowedMethod = (HttpMethod)intAllowedMethod; 607_http1Connection.Method = HttpMethod.Head; 618_http1Connection.Method = HttpMethod.Head; 629_http1Connection.Method = HttpMethod.Head;
HttpParserTests.cs (5)
13using HttpMethod = Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpMethod; 879public void OnStartLine(HttpMethod method, HttpVersion version, Span<byte> target, Span<byte> path, Span<byte> query, Span<byte> customMethod, bool pathEncoded) 881Method = method != HttpMethod.Custom ? HttpUtilities.MethodToString(method) : customMethod.GetAsciiStringNonNullCharacters(); 891var method = versionAndMethod.Method; 899Method = method != HttpMethod.Custom ? HttpUtilities.MethodToString(method) : customMethod.GetAsciiStringNonNullCharacters();
HttpUtilitiesTest.cs (19)
16[InlineData("CONNECT / HTTP/1.1", true, "CONNECT", (int)HttpMethod.Connect)] 17[InlineData("DELETE / HTTP/1.1", true, "DELETE", (int)HttpMethod.Delete)] 18[InlineData("GET / HTTP/1.1", true, "GET", (int)HttpMethod.Get)] 19[InlineData("HEAD / HTTP/1.1", true, "HEAD", (int)HttpMethod.Head)] 20[InlineData("PATCH / HTTP/1.1", true, "PATCH", (int)HttpMethod.Patch)] 21[InlineData("POST / HTTP/1.1", true, "POST", (int)HttpMethod.Post)] 22[InlineData("PUT / HTTP/1.1", true, "PUT", (int)HttpMethod.Put)] 23[InlineData("OPTIONS / HTTP/1.1", true, "OPTIONS", (int)HttpMethod.Options)] 24[InlineData("TRACE / HTTP/1.1", true, "TRACE", (int)HttpMethod.Trace)] 25[InlineData("GET/ HTTP/1.1", false, null, (int)HttpMethod.Custom)] 26[InlineData("get / HTTP/1.1", false, null, (int)HttpMethod.Custom)] 27[InlineData("GOT / HTTP/1.1", false, null, (int)HttpMethod.Custom)] 28[InlineData("ABC / HTTP/1.1", false, null, (int)HttpMethod.Custom)] 29[InlineData("PO / HTTP/1.1", false, null, (int)HttpMethod.Custom)] 30[InlineData("PO ST / HTTP/1.1", false, null, (int)HttpMethod.Custom)] 31[InlineData("short ", false, null, (int)HttpMethod.Custom)] 34var expectedMethod = (HttpMethod)intExpectedMethod; 42if (knownMethod != HttpMethod.Custom)
KnownStringsTests.cs (23)
48CreateTestDataEntry(_methodGet, (int)HttpMethod.Get, 3, true), 49CreateTestDataEntry(_methodPut, (int)HttpMethod.Put, 3, true), 50CreateTestDataEntry(_methodPost, (int)HttpMethod.Post, 4, true), 51CreateTestDataEntry(_methodHead, (int)HttpMethod.Head, 4, true), 52CreateTestDataEntry(_methodTrace, (int)HttpMethod.Trace, 5, true), 53CreateTestDataEntry(_methodPatch, (int)HttpMethod.Patch, 5, true), 54CreateTestDataEntry(_methodDelete, (int)HttpMethod.Delete, 6, true), 55CreateTestDataEntry(_methodConnect, (int)HttpMethod.Connect, 7, true), 56CreateTestDataEntry(_methodOptions, (int)HttpMethod.Options, 7, true), 57CreateTestDataEntry(_invalidMethod1, (int)HttpMethod.Custom, 0, false), 58CreateTestDataEntry(_invalidMethod2, (int)HttpMethod.Custom, 0, false), 59CreateTestDataEntry(_invalidMethod3, (int)HttpMethod.Custom, 0, false), 60CreateTestDataEntry(_invalidMethod4, (int)HttpMethod.Custom, 0, false), 61CreateTestDataEntry(_invalidMethod5, (int)HttpMethod.Custom, 0, false), 62CreateTestDataEntry(_invalidMethod6, (int)HttpMethod.Custom, 0, false), 63CreateTestDataEntry(_invalidMethod7, (int)HttpMethod.Custom, 0, false), 64CreateTestDataEntry(_invalidMethod8, (int)HttpMethod.Custom, 0, false), 65CreateTestDataEntry(_invalidMethod9, (int)HttpMethod.Custom, 0, false), 66CreateTestDataEntry(_invalidMethod10, (int)HttpMethod.Custom, 0, false), 67CreateTestDataEntry(_invalidMethod11, (int)HttpMethod.Custom, 0, false), 68CreateTestDataEntry(_invalidMethod12, (int)HttpMethod.Custom, 0, false), 77var expectedMethod = (HttpMethod)intExpectedMethod;
MessageBodyTests.cs (8)
558[InlineData((int)HttpMethod.Post)] 559[InlineData((int)HttpMethod.Put)] 562var method = (HttpMethod)intMethod; 573[InlineData((int)HttpMethod.Post)] 574[InlineData((int)HttpMethod.Put)] 577var method = (HttpMethod)intMethod;
src\Servers\Kestrel\shared\test\HttpParsingData.cs (2)
363data.Add($"{method} * HTTP/1.1\r\n", (int)HttpMethod.Options); 368data.Add($"{method} www.example.com:80 HTTP/1.1\r\n", (int)HttpMethod.Connect);
Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks (4)
Http1ConnectionBenchmark.cs (1)
15using HttpMethod = Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpMethod;
KnownStringsBenchmark.cs (1)
99HttpMethod method;
Mocks\NullParser.cs (2)
8using HttpMethod = Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpMethod; 39new HttpVersionAndMethod(HttpMethod.Get, 3) { Version = HttpVersion.Http11 },
Sockets.FunctionalTests (1)
SocketTransportTests.cs (1)
17using KestrelHttpMethod = Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpMethod;