From 811599f6d8f636fd0b43089acd4d5d4a338d8259 Mon Sep 17 00:00:00 2001 From: Caesar Chen Date: Wed, 31 Jan 2018 18:41:18 -0800 Subject: [PATCH 1/2] Update HttpStatusCode enum --- .../ref/System.Net.Primitives.cs | 19 ++++++++++++++ .../src/System/Net/HttpStatusCode.cs | 26 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/System.Net.Primitives/ref/System.Net.Primitives.cs b/src/System.Net.Primitives/ref/System.Net.Primitives.cs index f5123e3d7ec0..18fb3f7a3af9 100644 --- a/src/System.Net.Primitives/ref/System.Net.Primitives.cs +++ b/src/System.Net.Primitives/ref/System.Net.Primitives.cs @@ -172,6 +172,25 @@ public enum HttpStatusCode Unused = 306, UpgradeRequired = 426, UseProxy = 305, + Processing = 102, + EarlyHints = 103, + MultiStatus = 207, + AlreadyReported = 208, + IMUsed = 226, + PermanentRedirect = 308, + MisdirectedRequest = 421, + UnprocessableEntity = 422, + Locked = 423, + FailedDependency = 424, + PreconditionRequired = 428, + TooManyRequests = 429, + RequestHeaderFieldsTooLarge = 431, + UnavailableForLegalReasons = 451, + VariantAlsoNegotiates = 506, + InsufficientStorage = 507, + LoopDetected = 508, + NotExtended = 510, + NetworkAuthenticationRequired = 511, } public partial interface ICredentials { diff --git a/src/System.Net.Primitives/src/System/Net/HttpStatusCode.cs b/src/System.Net.Primitives/src/System/Net/HttpStatusCode.cs index 2dc66e3244a5..47a2c3b2708e 100644 --- a/src/System.Net.Primitives/src/System/Net/HttpStatusCode.cs +++ b/src/System.Net.Primitives/src/System/Net/HttpStatusCode.cs @@ -10,6 +10,8 @@ public enum HttpStatusCode // Informational 1xx Continue = 100, SwitchingProtocols = 101, + Processing = 102, + EarlyHints = 103, // Successful 2xx OK = 200, @@ -19,6 +21,10 @@ public enum HttpStatusCode NoContent = 204, ResetContent = 205, PartialContent = 206, + MultiStatus = 207, + AlreadyReported = 208, + + IMUsed = 226, // Redirection 3xx MultipleChoices = 300, @@ -34,6 +40,7 @@ public enum HttpStatusCode Unused = 306, TemporaryRedirect = 307, RedirectKeepVerb = 307, + PermanentRedirect = 308, // Client Error 4xx BadRequest = 400, @@ -54,9 +61,22 @@ public enum HttpStatusCode UnsupportedMediaType = 415, RequestedRangeNotSatisfiable = 416, ExpectationFailed = 417, + // Removed status code: ImATeapot = 418. + + MisdirectedRequest = 421, + UnprocessableEntity = 422, + Locked = 423, + FailedDependency = 424, UpgradeRequired = 426, + PreconditionRequired = 428, + TooManyRequests = 429, + + RequestHeaderFieldsTooLarge = 431, + + UnavailableForLegalReasons = 451, + // Server Error 5xx InternalServerError = 500, NotImplemented = 501, @@ -64,5 +84,11 @@ public enum HttpStatusCode ServiceUnavailable = 503, GatewayTimeout = 504, HttpVersionNotSupported = 505, + VariantAlsoNegotiates = 506, + InsufficientStorage = 507, + LoopDetected = 508, + + NotExtended = 510, + NetworkAuthenticationRequired = 511, } } From 2938b8db264f6fd9c05d59a529a04a98bd781f08 Mon Sep 17 00:00:00 2001 From: Caesar Chen Date: Wed, 31 Jan 2018 20:51:15 -0800 Subject: [PATCH 2/2] address feedback --- .../ref/System.Net.Primitives.cs | 38 +++++++++---------- .../src/System/Net/HttpStatusCode.cs | 7 +++- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/System.Net.Primitives/ref/System.Net.Primitives.cs b/src/System.Net.Primitives/ref/System.Net.Primitives.cs index 18fb3f7a3af9..775a21d3dc35 100644 --- a/src/System.Net.Primitives/ref/System.Net.Primitives.cs +++ b/src/System.Net.Primitives/ref/System.Net.Primitives.cs @@ -126,40 +126,55 @@ protected EndPoint() { } public enum HttpStatusCode { Accepted = 202, + AlreadyReported = 208, Ambiguous = 300, BadGateway = 502, BadRequest = 400, Conflict = 409, Continue = 100, Created = 201, + EarlyHints = 103, ExpectationFailed = 417, + FailedDependency = 424, Forbidden = 403, Found = 302, GatewayTimeout = 504, Gone = 410, HttpVersionNotSupported = 505, + IMUsed = 226, + InsufficientStorage = 507, InternalServerError = 500, LengthRequired = 411, + Locked = 423, + LoopDetected = 508, MethodNotAllowed = 405, + MisdirectedRequest = 421, Moved = 301, MovedPermanently = 301, MultipleChoices = 300, + MultiStatus = 207, + NetworkAuthenticationRequired = 511, NoContent = 204, NonAuthoritativeInformation = 203, NotAcceptable = 406, + NotExtended = 510, NotFound = 404, NotImplemented = 501, NotModified = 304, OK = 200, PartialContent = 206, PaymentRequired = 402, + PermanentRedirect = 308, PreconditionFailed = 412, + PreconditionRequired = 428, + Processing = 102, ProxyAuthenticationRequired = 407, Redirect = 302, RedirectKeepVerb = 307, RedirectMethod = 303, RequestedRangeNotSatisfiable = 416, RequestEntityTooLarge = 413, + RequestHeaderFieldsTooLarge = 431, RequestTimeout = 408, RequestUriTooLong = 414, ResetContent = 205, @@ -167,30 +182,15 @@ public enum HttpStatusCode ServiceUnavailable = 503, SwitchingProtocols = 101, TemporaryRedirect = 307, + TooManyRequests = 429, Unauthorized = 401, + UnavailableForLegalReasons = 451, + UnprocessableEntity = 422, UnsupportedMediaType = 415, Unused = 306, UpgradeRequired = 426, UseProxy = 305, - Processing = 102, - EarlyHints = 103, - MultiStatus = 207, - AlreadyReported = 208, - IMUsed = 226, - PermanentRedirect = 308, - MisdirectedRequest = 421, - UnprocessableEntity = 422, - Locked = 423, - FailedDependency = 424, - PreconditionRequired = 428, - TooManyRequests = 429, - RequestHeaderFieldsTooLarge = 431, - UnavailableForLegalReasons = 451, - VariantAlsoNegotiates = 506, - InsufficientStorage = 507, - LoopDetected = 508, - NotExtended = 510, - NetworkAuthenticationRequired = 511, + VariantAlsoNegotiates = 506 } public partial interface ICredentials { diff --git a/src/System.Net.Primitives/src/System/Net/HttpStatusCode.cs b/src/System.Net.Primitives/src/System/Net/HttpStatusCode.cs index 47a2c3b2708e..e46a925a3388 100644 --- a/src/System.Net.Primitives/src/System/Net/HttpStatusCode.cs +++ b/src/System.Net.Primitives/src/System/Net/HttpStatusCode.cs @@ -61,7 +61,10 @@ public enum HttpStatusCode UnsupportedMediaType = 415, RequestedRangeNotSatisfiable = 416, ExpectationFailed = 417, - // Removed status code: ImATeapot = 418. + // From the discussion thread on #4382: + // "It would be a mistake to add it to .NET now. See golang/go#21326, + // nodejs/node#14644, requests/requests#4238 and aspnet/HttpAbstractions#915". + // ImATeapot = 418 MisdirectedRequest = 421, UnprocessableEntity = 422, @@ -89,6 +92,6 @@ public enum HttpStatusCode LoopDetected = 508, NotExtended = 510, - NetworkAuthenticationRequired = 511, + NetworkAuthenticationRequired = 511 } }