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)
611
var methods = new
HttpMethod
[] {
612
HttpMethod
.Connect,
613
HttpMethod
.Delete,
614
HttpMethod
.Get,
615
HttpMethod
.Head,
616
HttpMethod
.Options,
617
HttpMethod
.Patch,
618
HttpMethod
.Post,
619
HttpMethod
.Put,
620
HttpMethod
.Trace
625
foreach (
var
method in methods)
634
public async Task AttemptingToWriteNonzeroContentLengthFailsFor1xxAnd204Responses(int statusCode,
HttpMethod
method)
639
public async Task AttemptingToWriteZeroContentLengthFor1xxAnd204Responses_ContentLengthRemoved(int statusCode,
HttpMethod
method)
654
=> await AttemptingToWriteNonzeroContentLengthFails(statusCode,
HttpMethod
.Connect).ConfigureAwait(true);
668
=> await AttemptingToWriteZeroContentLength_ContentLengthRemoved(statusCode,
HttpMethod
.Connect).ConfigureAwait(true);
670
private async Task AttemptingToWriteNonzeroContentLengthFails(int statusCode,
HttpMethod
method)
711
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)
299
var
method = versionAndMethod.Method;
325
if (method ==
HttpMethod
.Custom)
452
private void OnAuthorityFormTarget(
HttpMethod
method, Span<byte> target)
465
if (method !=
HttpMethod
.Connect)
503
private void OnAsteriskFormTarget(
HttpMethod
method)
509
if (method !=
HttpMethod
.Options)
Internal\Http\Http1MessageBody.cs (2)
208
if (httpVersion == HttpVersion.Http10 && (context.Method ==
HttpMethod
.Post || context.Method ==
HttpMethod
.Put))
Internal\Http\HttpParser.cs (2)
86
var
method = requestLine.GetKnownMethod(out var methodEnd);
87
if (method ==
HttpMethod
.Custom)
Internal\Http\HttpProtocol.cs (9)
149
public
HttpMethod
Method { get; set; }
361
Method =
HttpMethod
.None;
913
if (Method !=
HttpMethod
.Head &&
1092
if (Method ==
HttpMethod
.Head && _responseBytesWritten > 0)
1113
if (Method ==
HttpMethod
.Head && _responseBytesWritten > 0)
1272
else if (Method ==
HttpMethod
.Connect && Is2xxCode(StatusCode))
1288
return Method !=
HttpMethod
.Head &&
1298
Method !=
HttpMethod
.Head &&
1370
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)
250
if (Method ==
HttpMethod
.None && !TryValidateMethod())
260
if (Method ==
HttpMethod
.Connect)
324
if (Method ==
HttpMethod
.Options && path.Length == 1 && path[0] == '*')
354
if (Method ==
HttpMethod
.None)
360
if (Method ==
HttpMethod
.Custom)
701
Method =
HttpMethod
.Get;
706
Method =
HttpMethod
.Post;
Internal\Http3\Http3Stream.cs (7)
22
using HttpMethod = Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.
HttpMethod
;
248
Method =
HttpMethod
.Get;
253
Method =
HttpMethod
.Post;
1002
if (Method ==
HttpMethod
.Connect && HttpRequestHeaders.HeaderProtocol.Count == 0)
1045
if (Method ==
HttpMethod
.Options && path.Length == 1 && path[0] == '*')
1075
if (Method ==
HttpMethod
.None)
1081
if (Method ==
HttpMethod
.Custom)
Internal\Infrastructure\HttpUtilities.cs (28)
33
private static void SetKnownMethod(ulong mask, ulong knownMethodUlong,
HttpMethod
knownMethod, int length)
35
_knownMethods[GetKnownMethodIndex(knownMethodUlong)] = new Tuple<ulong, ulong,
HttpMethod
, int>(mask, knownMethodUlong, knownMethod, length);
42
var invalidHttpMethod = new Tuple<ulong, ulong,
HttpMethod
, int>(_mask8Chars, 0ul,
HttpMethod
.Custom, 0);
207
public static bool GetKnownMethod(this ReadOnlySpan<byte> span, out
HttpMethod
method, out int length)
210
return method !=
HttpMethod
.Custom;
214
public static
HttpMethod
GetKnownMethod(this ReadOnlySpan<byte> span, out int methodLength)
222
return
HttpMethod
.Get;
242
return
HttpMethod
.Custom;
252
/// <returns><see cref="
HttpMethod
"/></returns>
253
public static
HttpMethod
GetKnownMethod(string? value)
274
return
HttpMethod
.None;
293
return
HttpMethod
.Custom;
335
static ReadOnlySpan<
HttpMethod
> Methods() =>
337
HttpMethod
.None,
338
HttpMethod
.None,
339
HttpMethod
.None,
340
HttpMethod
.Get,
341
HttpMethod
.Head,
342
HttpMethod
.Trace,
343
HttpMethod
.Delete,
344
HttpMethod
.Options,
345
HttpMethod
.Put,
346
HttpMethod
.Post,
347
HttpMethod
.Patch,
348
HttpMethod
.None,
349
HttpMethod
.Connect
470
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)
555
var
allowedMethod = (
HttpMethod
)intAllowedMethod;
610
_http1Connection.Method =
HttpMethod
.Head;
621
_http1Connection.Method =
HttpMethod
.Head;
632
_http1Connection.Method =
HttpMethod
.Head;
HttpParserTests.cs (5)
13
using HttpMethod = Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.
HttpMethod
;
894
public void OnStartLine(
HttpMethod
method, HttpVersion version, Span<byte> target, Span<byte> path, Span<byte> query, Span<byte> customMethod, bool pathEncoded)
896
Method = method !=
HttpMethod
.Custom ? HttpUtilities.MethodToString(method) : customMethod.GetAsciiString();
906
var
method = versionAndMethod.Method;
914
Method = method !=
HttpMethod
.Custom ? HttpUtilities.MethodToString(method) : customMethod.GetAsciiString();
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
;