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