| | | 1 | | namespace ArturRios.Util.Http; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Provides common HTTP status code constants and grouped collections for convenience. |
| | | 5 | | /// </summary> |
| | | 6 | | public static class HttpStatusCodes |
| | | 7 | | { |
| | | 8 | | /// <summary>HTTP 200 - OK.</summary> |
| | | 9 | | public const int Ok = 200; |
| | | 10 | | /// <summary>HTTP 201 - Created.</summary> |
| | | 11 | | public const int Created = 201; |
| | | 12 | | /// <summary>HTTP 202 - Accepted.</summary> |
| | | 13 | | public const int Accepted = 202; |
| | | 14 | | /// <summary>HTTP 204 - No Content.</summary> |
| | | 15 | | public const int NoContent = 204; |
| | | 16 | | |
| | | 17 | | /// <summary>HTTP 301 - Moved Permanently.</summary> |
| | | 18 | | public const int MovedPermanently = 301; |
| | | 19 | | /// <summary>HTTP 302 - Found.</summary> |
| | | 20 | | public const int Found = 302; |
| | | 21 | | /// <summary>HTTP 304 - Not Modified.</summary> |
| | | 22 | | public const int NotModified = 304; |
| | | 23 | | /// <summary>HTTP 307 - Temporary Redirect.</summary> |
| | | 24 | | public const int TemporaryRedirect = 307; |
| | | 25 | | /// <summary>HTTP 308 - Permanent Redirect.</summary> |
| | | 26 | | public const int PermanentRedirect = 308; |
| | | 27 | | |
| | | 28 | | /// <summary>HTTP 400 - Bad Request.</summary> |
| | | 29 | | public const int BadRequest = 400; |
| | | 30 | | /// <summary>HTTP 401 - Unauthorized.</summary> |
| | | 31 | | public const int Unauthorized = 401; |
| | | 32 | | /// <summary>HTTP 403 - Forbidden.</summary> |
| | | 33 | | public const int Forbidden = 403; |
| | | 34 | | /// <summary>HTTP 404 - Not Found.</summary> |
| | | 35 | | public const int NotFound = 404; |
| | | 36 | | /// <summary>HTTP 405 - Method Not Allowed.</summary> |
| | | 37 | | public const int MethodNotAllowed = 405; |
| | | 38 | | /// <summary>HTTP 409 - Conflict.</summary> |
| | | 39 | | public const int Conflict = 409; |
| | | 40 | | /// <summary>HTTP 422 - Unprocessable Entity.</summary> |
| | | 41 | | public const int UnprocessableEntity = 422; |
| | | 42 | | /// <summary>HTTP 429 - Too Many Requests.</summary> |
| | | 43 | | public const int TooManyRequests = 429; |
| | | 44 | | |
| | | 45 | | /// <summary>HTTP 500 - Internal Server Error.</summary> |
| | | 46 | | public const int InternalServerError = 500; |
| | | 47 | | /// <summary>HTTP 501 - Not Implemented.</summary> |
| | | 48 | | public const int NotImplemented = 501; |
| | | 49 | | /// <summary>HTTP 502 - Bad Gateway.</summary> |
| | | 50 | | public const int BadGateway = 502; |
| | | 51 | | /// <summary>HTTP 503 - Service Unavailable.</summary> |
| | | 52 | | public const int ServiceUnavailable = 503; |
| | | 53 | | /// <summary>HTTP 504 - Gateway Timeout.</summary> |
| | | 54 | | public const int GatewayTimeout = 504; |
| | | 55 | | |
| | | 56 | | /// <summary> |
| | | 57 | | /// Group containing success status codes (2xx). |
| | | 58 | | /// </summary> |
| | 29 | 59 | | public static int[] Success => [Ok, Created, Accepted, NoContent]; |
| | | 60 | | |
| | | 61 | | /// <summary> |
| | | 62 | | /// Group containing redirection status codes (3xx). |
| | | 63 | | /// </summary> |
| | 30 | 64 | | public static int[] Redirection => [MovedPermanently, Found, NotModified, TemporaryRedirect, PermanentRedirect]; |
| | | 65 | | |
| | | 66 | | /// <summary> |
| | | 67 | | /// Group containing client error status codes (4xx). |
| | | 68 | | /// </summary> |
| | | 69 | | public static int[] ClientError => |
| | 33 | 70 | | [BadRequest, Unauthorized, Forbidden, NotFound, MethodNotAllowed, Conflict, UnprocessableEntity, TooManyRequests |
| | | 71 | | |
| | | 72 | | /// <summary> |
| | | 73 | | /// Group containing server error status codes (5xx). |
| | | 74 | | /// </summary> |
| | 30 | 75 | | public static int[] ServerError => [InternalServerError, NotImplemented, BadGateway, ServiceUnavailable, GatewayTime |
| | | 76 | | |
| | | 77 | | /// <summary> |
| | | 78 | | /// Convenience property containing all supported status codes. |
| | | 79 | | /// </summary> |
| | 23 | 80 | | public static int[] All => [..Success, ..Redirection, ..ClientError, ..ServerError]; |
| | | 81 | | } |