| 1 | #ifndef _CPR_STATUS_CODES |
| 2 | #define _CPR_STATUS_CODES |
| 3 | #include <cstdint> |
| 4 | namespace cpr { |
| 5 | namespace status { |
| 6 | // Information responses |
| 7 | constexpr std::int32_t HTTP_CONTINUE = 100; |
| 8 | constexpr std::int32_t HTTP_SWITCHING_PROTOCOL = 101; |
| 9 | constexpr std::int32_t HTTP_PROCESSING = 102; |
| 10 | constexpr std::int32_t HTTP_EARLY_HINTS = 103; |
| 11 | // Successful responses |
| 12 | constexpr std::int32_t HTTP_OK = 200; |
| 13 | constexpr std::int32_t HTTP_CREATED = 201; |
| 14 | constexpr std::int32_t HTTP_ACCEPTED = 202; |
| 15 | constexpr std::int32_t HTTP_NON_AUTHORITATIVE_INFORMATION = 203; |
| 16 | constexpr std::int32_t HTTP_NO_CONTENT = 204; |
| 17 | constexpr std::int32_t HTTP_RESET_CONTENT = 205; |
| 18 | constexpr std::int32_t HTTP_PARTIAL_CONTENT = 206; |
| 19 | constexpr std::int32_t HTTP_MULTI_STATUS = 207; |
| 20 | constexpr std::int32_t HTTP_ALREADY_REPORTED = 208; |
| 21 | constexpr std::int32_t HTTP_IM_USED = 226; |
| 22 | // Redirection messages |
| 23 | constexpr std::int32_t HTTP_MULTIPLE_CHOICE = 300; |
| 24 | constexpr std::int32_t HTTP_MOVED_PERMANENTLY = 301; |
| 25 | constexpr std::int32_t HTTP_FOUND = 302; |
| 26 | constexpr std::int32_t HTTP_SEE_OTHER = 303; |
| 27 | constexpr std::int32_t HTTP_NOT_MODIFIED = 304; |
| 28 | constexpr std::int32_t HTTP_USE_PROXY = 305; |
| 29 | constexpr std::int32_t HTTP_UNUSED = 306; |
| 30 | constexpr std::int32_t HTTP_TEMPORARY_REDIRECT = 307; |
| 31 | constexpr std::int32_t HTTP_PERMANENT_REDIRECT = 308; |
| 32 | // Client error responses |
| 33 | constexpr std::int32_t HTTP_BAD_REQUEST = 400; |
| 34 | constexpr std::int32_t HTTP_UNAUTHORIZED = 401; |
| 35 | constexpr std::int32_t HTTP_PAYMENT_REQUIRED = 402; |
| 36 | constexpr std::int32_t HTTP_FORBIDDEN = 403; |
| 37 | constexpr std::int32_t HTTP_NOT_FOUND = 404; |
| 38 | constexpr std::int32_t HTTP_METHOD_NOT_ALLOWED = 405; |
| 39 | constexpr std::int32_t HTTP_NOT_ACCEPTABLE = 406; |
| 40 | constexpr std::int32_t HTTP_PROXY_AUTHENTICATION_REQUIRED = 407; |
| 41 | constexpr std::int32_t HTTP_REQUEST_TIMEOUT = 408; |
| 42 | constexpr std::int32_t HTTP_CONFLICT = 409; |
| 43 | constexpr std::int32_t HTTP_GONE = 410; |
| 44 | constexpr std::int32_t HTTP_LENGTH_REQUIRED = 411; |
| 45 | constexpr std::int32_t HTTP_PRECONDITION_FAILED = 412; |
| 46 | constexpr std::int32_t HTTP_PAYLOAD_TOO_LARGE = 413; |
| 47 | constexpr std::int32_t HTTP_URI_TOO_LONG = 414; |
| 48 | constexpr std::int32_t HTTP_UNSUPPORTED_MEDIA_TYPE = 415; |
| 49 | constexpr std::int32_t HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416; |
| 50 | constexpr std::int32_t HTTP_EXPECTATION_FAILED = 417; |
| 51 | constexpr std::int32_t HTTP_IM_A_TEAPOT = 418; |
| 52 | constexpr std::int32_t HTTP_MISDIRECTED_REQUEST = 421; |
| 53 | constexpr std::int32_t HTTP_UNPROCESSABLE_ENTITY = 422; |
| 54 | constexpr std::int32_t HTTP_LOCKED = 423; |
| 55 | constexpr std::int32_t HTTP_FAILED_DEPENDENCY = 424; |
| 56 | constexpr std::int32_t HTTP_TOO_EARLY = 425; |
| 57 | constexpr std::int32_t HTTP_UPGRADE_REQUIRED = 426; |
| 58 | constexpr std::int32_t HTTP_PRECONDITION_REQUIRED = 428; |
| 59 | constexpr std::int32_t HTTP_TOO_MANY_REQUESTS = 429; |
| 60 | constexpr std::int32_t = 431; |
| 61 | constexpr std::int32_t HTTP_UNAVAILABLE_FOR_LEGAL_REASONS = 451; |
| 62 | // Server response errors |
| 63 | constexpr std::int32_t HTTP_INTERNAL_SERVER_ERROR = 500; |
| 64 | constexpr std::int32_t HTTP_NOT_IMPLEMENTED = 501; |
| 65 | constexpr std::int32_t HTTP_BAD_GATEWAY = 502; |
| 66 | constexpr std::int32_t HTTP_SERVICE_UNAVAILABLE = 503; |
| 67 | constexpr std::int32_t HTTP_GATEWAY_TIMEOUT = 504; |
| 68 | constexpr std::int32_t HTTP_HTTP_VERSION_NOT_SUPPORTED = 505; |
| 69 | constexpr std::int32_t HTTP_VARIANT_ALSO_NEGOTIATES = 506; |
| 70 | constexpr std::int32_t HTTP_INSUFFICIENT_STORAGE = 507; |
| 71 | constexpr std::int32_t HTTP_LOOP_DETECTED = 508; |
| 72 | constexpr std::int32_t HTTP_NOT_EXTENDED = 510; |
| 73 | constexpr std::int32_t HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511; |
| 74 | |
| 75 | constexpr std::int32_t INFO_CODE_OFFSET = 100; |
| 76 | constexpr std::int32_t SUCCESS_CODE_OFFSET = 200; |
| 77 | constexpr std::int32_t REDIRECT_CODE_OFFSET = 300; |
| 78 | constexpr std::int32_t CLIENT_ERROR_CODE_OFFSET = 400; |
| 79 | constexpr std::int32_t SERVER_ERROR_CODE_OFFSET = 500; |
| 80 | constexpr std::int32_t MISC_CODE_OFFSET = 600; |
| 81 | |
| 82 | constexpr bool is_informational(const std::int32_t code) { |
| 83 | return (code >= INFO_CODE_OFFSET && code < SUCCESS_CODE_OFFSET); |
| 84 | } |
| 85 | constexpr bool is_success(const std::int32_t code) { |
| 86 | return (code >= SUCCESS_CODE_OFFSET && code < REDIRECT_CODE_OFFSET); |
| 87 | } |
| 88 | constexpr bool is_redirect(const std::int32_t code) { |
| 89 | return (code >= REDIRECT_CODE_OFFSET && code < CLIENT_ERROR_CODE_OFFSET); |
| 90 | } |
| 91 | constexpr bool is_client_error(const std::int32_t code) { |
| 92 | return (code >= CLIENT_ERROR_CODE_OFFSET && code < SERVER_ERROR_CODE_OFFSET); |
| 93 | } |
| 94 | constexpr bool is_server_error(const std::int32_t code) { |
| 95 | return (code >= SERVER_ERROR_CODE_OFFSET && code < MISC_CODE_OFFSET); |
| 96 | } |
| 97 | |
| 98 | } // namespace status |
| 99 | } // namespace cpr |
| 100 | #endif |