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