Skip to content

Commit d39fda0

Browse files
authored
Add StatusCode enum (#1739)
* Add StatusCode enum * Remove changes on RFC 9110 * Add number suffixes to StatusCode constants * Remove docs for StatusCode constants
1 parent 37f8dc4 commit d39fda0

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

httplib.h

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,6 +1791,81 @@ inline void default_socket_options(socket_t sock) {
17911791
#endif
17921792
}
17931793

1794+
enum StatusCode {
1795+
// Information responses
1796+
Continue_100 = 100,
1797+
SwitchingProtocol_101 = 101,
1798+
Processing_102 = 102,
1799+
EarlyHints_103 = 103,
1800+
1801+
// Successful responses
1802+
OK_200 = 200,
1803+
Created_201 = 201,
1804+
Accepted_202 = 202,
1805+
NonAuthoritativeInformation_203 = 203,
1806+
NoContent_204 = 204,
1807+
ResetContent_205 = 205,
1808+
PartialContent_206 = 206,
1809+
MultiStatus_207 = 207,
1810+
AlreadyReported_208 = 208,
1811+
IMUsed_226 = 226,
1812+
1813+
// Redirection messages
1814+
MultipleChoices_300 = 300,
1815+
MovedPermanently_301 = 301,
1816+
Found_302 = 302,
1817+
SeeOther_303 = 303,
1818+
NotModified_304 = 304,
1819+
UseProxy_305 = 305,
1820+
unused_306 = 306,
1821+
TemporaryRedirect_307 = 307,
1822+
PermanentRedirect_308 = 308,
1823+
1824+
// Client error responses
1825+
BadRequest_400 = 400,
1826+
Unauthorized_401 = 401,
1827+
PaymentRequired_402 = 402,
1828+
Forbidden_403 = 403,
1829+
NotFound_404 = 404,
1830+
MethodNotAllowed_405 = 405,
1831+
NotAcceptable_406 = 406,
1832+
ProxyAuthenticationRequired_407 = 407,
1833+
RequestTimeout_408 = 408,
1834+
Conflict_409 = 409,
1835+
Gone_410 = 410,
1836+
LengthRequired_411 = 411,
1837+
PreconditionFailed_412 = 412,
1838+
PayloadTooLarge_413 = 413,
1839+
UriTooLong_414 = 414,
1840+
UnsupportedMediaType_415 = 415,
1841+
RangeNotSatisfiable_416 = 416,
1842+
ExpectationFailed_417 = 417,
1843+
ImATeapot_418 = 418,
1844+
MisdirectedRequest_421 = 421,
1845+
UnprocessableContent_422 = 422,
1846+
Locked_423 = 423,
1847+
FailedDependency_424 = 424,
1848+
TooEarly_425 = 425,
1849+
UpgradeRequired_426 = 426,
1850+
PreconditionRequired_428 = 428,
1851+
TooManyRequests_429 = 429,
1852+
RequestHeaderFieldsTooLarge_431 = 431,
1853+
UnavailableForLegalReasons_451 = 451,
1854+
1855+
// Server error responses
1856+
InternalServerError_500 = 500,
1857+
NotImplemented_501 = 501,
1858+
BadGateway_502 = 502,
1859+
ServiceUnavailable_503 = 503,
1860+
GatewayTimeout_504 = 504,
1861+
HttpVersionNotSupported_505 = 505,
1862+
VariantAlsoNegotiates_506 = 506,
1863+
InsufficientStorage_507 = 507,
1864+
LoopDetected_508 = 508,
1865+
NotExtended_510 = 510,
1866+
NetworkAuthenticationRequired_511 = 511,
1867+
};
1868+
17941869
inline const char *status_message(int status) {
17951870
switch (status) {
17961871
case 100: return "Continue";

0 commit comments

Comments
 (0)