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