Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit 7d20ae2

Browse files
committed
Add more status codes and reason phrases
1 parent b34bfdd commit 7d20ae2

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/Microsoft.AspNetCore.Http.Abstractions/StatusCodes.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33

44
namespace Microsoft.AspNetCore.Http
55
{
6+
// Status Codes listed at http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
67
public static class StatusCodes
78
{
9+
public const int Status100Continue = 100;
810
public const int Status101SwitchingProtocols = 101;
911

1012
public const int Status200OK = 200;
@@ -46,9 +48,14 @@ public static class StatusCodes
4648
public const int Status417ExpectationFailed = 417;
4749
public const int Status418ImATeapot = 418;
4850
public const int Status419AuthenticationTimeout = 419;
51+
public const int Status421MisdirectedRequest = 421;
4952
public const int Status422UnprocessableEntity = 422;
5053
public const int Status423Locked = 423;
5154
public const int Status424FailedDependency = 424;
55+
public const int Status426UpgradeRequired = 426;
56+
public const int Status428PreconditionRequired = 428;
57+
public const int Status429TooManyRequests = 429;
58+
public const int Status431RequestHeaderFieldsTooLarge = 431;
5259
public const int Status451UnavailableForLegalReasons = 451;
5360

5461
public const int Status500InternalServerError = 500;
@@ -59,5 +66,7 @@ public static class StatusCodes
5966
public const int Status505HttpVersionNotsupported = 505;
6067
public const int Status506VariantAlsoNegotiates = 506;
6168
public const int Status507InsufficientStorage = 507;
69+
public const int Status510NotExtended = 510;
70+
public const int Status511NetworkAuthenticationRequired = 511;
6271
}
6372
}

src/Microsoft.AspNetCore.WebUtilities/ReasonPhrases.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ namespace Microsoft.AspNetCore.WebUtilities
77
{
88
public static class ReasonPhrases
99
{
10+
// Status Codes listed at http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
1011
private static IDictionary<int, string> Phrases = new Dictionary<int, string>()
1112
{
13+
{ 100, "Continue" },
1214
{ 101, "Switching Protocols" },
1315

1416
{ 200, "OK" },
@@ -18,6 +20,7 @@ public static class ReasonPhrases
1820
{ 204, "No Content" },
1921
{ 205, "Reset Content" },
2022
{ 206, "Partial Content" },
23+
{ 207, "Multi-Status" },
2124

2225
{ 300, "Multiple Choices" },
2326
{ 301, "Moved Permanently" },
@@ -27,6 +30,7 @@ public static class ReasonPhrases
2730
{ 305, "Use Proxy" },
2831
{ 306, "Switch Proxy" },
2932
{ 307, "Temporary Redirect" },
33+
{ 308, "Permanent Redirect" },
3034

3135
{ 400, "Bad Request" },
3236
{ 401, "Unauthorized" },
@@ -48,6 +52,15 @@ public static class ReasonPhrases
4852
{ 417, "Expectation Failed" },
4953
{ 418, "I'm a teapot" },
5054
{ 419, "Authentication Timeout" },
55+
{ 421, "Misdirected Request" },
56+
{ 422, "Unprocessable Entity" },
57+
{ 423, "Locked" },
58+
{ 424, "Failed Dependency" },
59+
{ 426, "Upgrade Required" },
60+
{ 428, "Precondition Required" },
61+
{ 429, "Too Many Requests" },
62+
{ 431, "Request Header Fields Too Large" },
63+
{ 451, "Unavailable For Legal Reasons" },
5164

5265
{ 500, "Internal Server Error" },
5366
{ 501, "Not Implemented" },
@@ -56,6 +69,9 @@ public static class ReasonPhrases
5669
{ 504, "Gateway Timeout" },
5770
{ 505, "HTTP Version Not Supported" },
5871
{ 506, "Variant Also Negotiates" },
72+
{ 507, "Insufficient Storage" },
73+
{ 510, "Not Extended" },
74+
{ 511, "Network Authentication Required" },
5975
};
6076

6177
public static string GetReasonPhrase(int statusCode)

0 commit comments

Comments
 (0)