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

Add more status codes and reason phrases #749

Merged
merged 1 commit into from
Jan 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Microsoft.AspNetCore.Http.Abstractions/StatusCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

namespace Microsoft.AspNetCore.Http
{
// Status Codes listed at http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
public static class StatusCodes
{
public const int Status100Continue = 100;
public const int Status101SwitchingProtocols = 101;

public const int Status200OK = 200;
Expand Down Expand Up @@ -46,9 +48,14 @@ public static class StatusCodes
public const int Status417ExpectationFailed = 417;
public const int Status418ImATeapot = 418;
public const int Status419AuthenticationTimeout = 419;
public const int Status421MisdirectedRequest = 421;
public const int Status422UnprocessableEntity = 422;
public const int Status423Locked = 423;
public const int Status424FailedDependency = 424;
public const int Status426UpgradeRequired = 426;
public const int Status428PreconditionRequired = 428;
public const int Status429TooManyRequests = 429;
public const int Status431RequestHeaderFieldsTooLarge = 431;
public const int Status451UnavailableForLegalReasons = 451;

public const int Status500InternalServerError = 500;
Expand All @@ -59,5 +66,7 @@ public static class StatusCodes
public const int Status505HttpVersionNotsupported = 505;
public const int Status506VariantAlsoNegotiates = 506;
public const int Status507InsufficientStorage = 507;
public const int Status510NotExtended = 510;
public const int Status511NetworkAuthenticationRequired = 511;
}
}
16 changes: 16 additions & 0 deletions src/Microsoft.AspNetCore.WebUtilities/ReasonPhrases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ namespace Microsoft.AspNetCore.WebUtilities
{
public static class ReasonPhrases
{
// Status Codes listed at http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
private static IDictionary<int, string> Phrases = new Dictionary<int, string>()
{
{ 100, "Continue" },
{ 101, "Switching Protocols" },

{ 200, "OK" },
Expand All @@ -18,6 +20,7 @@ public static class ReasonPhrases
{ 204, "No Content" },
{ 205, "Reset Content" },
{ 206, "Partial Content" },
{ 207, "Multi-Status" },

{ 300, "Multiple Choices" },
{ 301, "Moved Permanently" },
Expand All @@ -27,6 +30,7 @@ public static class ReasonPhrases
{ 305, "Use Proxy" },
{ 306, "Switch Proxy" },
{ 307, "Temporary Redirect" },
{ 308, "Permanent Redirect" },

{ 400, "Bad Request" },
{ 401, "Unauthorized" },
Expand All @@ -48,6 +52,15 @@ public static class ReasonPhrases
{ 417, "Expectation Failed" },
{ 418, "I'm a teapot" },
{ 419, "Authentication Timeout" },
{ 421, "Misdirected Request" },
{ 422, "Unprocessable Entity" },
{ 423, "Locked" },
{ 424, "Failed Dependency" },
{ 426, "Upgrade Required" },
{ 428, "Precondition Required" },
{ 429, "Too Many Requests" },
{ 431, "Request Header Fields Too Large" },
{ 451, "Unavailable For Legal Reasons" },

{ 500, "Internal Server Error" },
{ 501, "Not Implemented" },
Expand All @@ -56,6 +69,9 @@ public static class ReasonPhrases
{ 504, "Gateway Timeout" },
{ 505, "HTTP Version Not Supported" },
{ 506, "Variant Also Negotiates" },
{ 507, "Insufficient Storage" },
{ 510, "Not Extended" },
{ 511, "Network Authentication Required" },
};

public static string GetReasonPhrase(int statusCode)
Expand Down