Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add StatusCode enum #1739

Merged
merged 4 commits into from
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions httplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,81 @@ inline void default_socket_options(socket_t sock) {
#endif
}

enum StatusCode {
// Information responses
Continue_100 = 100,
SwitchingProtocol_101 = 101,
Processing_102 = 102,
EarlyHints_103 = 103,

// Successful responses
OK_200 = 200,
Created_201 = 201,
Accepted_202 = 202,
NonAuthoritativeInformation_203 = 203,
NoContent_204 = 204,
ResetContent_205 = 205,
PartialContent_206 = 206,
MultiStatus_207 = 207,
AlreadyReported_208 = 208,
IMUsed_226 = 226,

// Redirection messages
MultipleChoices_300 = 300,
MovedPermanently_301 = 301,
Found_302 = 302,
SeeOther_303 = 303,
NotModified_304 = 304,
UseProxy_305 = 305,
unused_306 = 306,
TemporaryRedirect_307 = 307,
PermanentRedirect_308 = 308,

// Client error responses
BadRequest_400 = 400,
Unauthorized_401 = 401,
PaymentRequired_402 = 402,
Forbidden_403 = 403,
NotFound_404 = 404,
MethodNotAllowed_405 = 405,
NotAcceptable_406 = 406,
ProxyAuthenticationRequired_407 = 407,
RequestTimeout_408 = 408,
Conflict_409 = 409,
Gone_410 = 410,
LengthRequired_411 = 411,
PreconditionFailed_412 = 412,
PayloadTooLarge_413 = 413,
UriTooLong_414 = 414,
UnsupportedMediaType_415 = 415,
RangeNotSatisfiable_416 = 416,
ExpectationFailed_417 = 417,
ImATeapot_418 = 418,
MisdirectedRequest_421 = 421,
UnprocessableContent_422 = 422,
Locked_423 = 423,
FailedDependency_424 = 424,
TooEarly_425 = 425,
UpgradeRequired_426 = 426,
PreconditionRequired_428 = 428,
TooManyRequests_429 = 429,
RequestHeaderFieldsTooLarge_431 = 431,
UnavailableForLegalReasons_451 = 451,

// Server error responses
InternalServerError_500 = 500,
NotImplemented_501 = 501,
BadGateway_502 = 502,
ServiceUnavailable_503 = 503,
GatewayTimeout_504 = 504,
HttpVersionNotSupported_505 = 505,
VariantAlsoNegotiates_506 = 506,
InsufficientStorage_507 = 507,
LoopDetected_508 = 508,
NotExtended_510 = 510,
NetworkAuthenticationRequired_511 = 511,
};

inline const char *status_message(int status) {
switch (status) {
case 100: return "Continue";
Expand Down