Skip to content

Commit

Permalink
Add missing HTTP status codes
Browse files Browse the repository at this point in the history
  • Loading branch information
pfirsich committed Nov 20, 2024
1 parent 7c77cd5 commit 1c43fd0
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/http/Status.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ static constexpr struct {
} http_status_to_string_input[] = {
{ HttpStatus::CONTINUE, "100 Continue" },
{ HttpStatus::SWITCHING_PROTOCOLS, "101 Switching Protocols" },
{ HttpStatus::PROCESSING, "102 Processing"},
{ HttpStatus::EARLY_HINTS, "103 Early Hints"},
{ HttpStatus::OK, "200 OK" },
{ HttpStatus::CREATED, "201 Created" },
{ HttpStatus::ACCEPTED, "202 Accepted" },
Expand All @@ -19,13 +21,16 @@ static constexpr struct {
{ HttpStatus::RESET_CONTENT, "205 Reset Content" },
{ HttpStatus::PARTIAL_CONTENT, "206 Partial Content" },
{ HttpStatus::MULTI_STATUS, "207 Multi-Status" },
{ HttpStatus::ALREADY_REPORTED, "208 Already Reported"},
{ HttpStatus::IM_USED, "226 IM Used"},
{ HttpStatus::MULTIPLE_CHOICES, "300 Multiple Choices" },
{ HttpStatus::MOVED_PERMANENTLY, "301 Moved Permanently" },
{ HttpStatus::FOUND, "302 Found" },
{ HttpStatus::SEE_OTHER, "303 See Other" },
{ HttpStatus::NOT_MODIFIED, "304 Not Modified" },
{ HttpStatus::USE_PROXY, "305 Use Proxy" },
{ HttpStatus::TEMPORARY_REDIRECT, "307 Temporary Redirect" },
{ HttpStatus::PERMANENT_REDIRECT, "308 Permanent Redirect"},
{ HttpStatus::BAD_REQUEST, "400 Bad Request" },
{ HttpStatus::UNAUTHORIZED, "401 Unauthorized" },
{ HttpStatus::PAYMENT_REQUIRED, "402 Payment Required" },
Expand All @@ -48,9 +53,11 @@ static constexpr struct {
"416 Requested Range Not Satisfiable" },
{ HttpStatus::EXPECTATION_FAILED, "417 Expectation failed" },
{ HttpStatus::I_M_A_TEAPOT, "418 I'm a teapot" },
{ HttpStatus::MISDIRECTED_REQUEST, "421 Misdirected Request"},
{ HttpStatus::UNPROCESSABLE_ENTITY, "422 Unprocessable Entity" },
{ HttpStatus::LOCKED, "423 Locked" },
{ HttpStatus::FAILED_DEPENDENCY, "424 Failed Dependency" },
{ HttpStatus::TOO_EARLY, "425 Too Early"},
{ HttpStatus::UPGRADE_REQUIRED, "426 Upgrade Required" },
{ HttpStatus::PRECONDITION_REQUIRED, "428 Precondition Required" },
{ HttpStatus::TOO_MANY_REQUESTS, "429 Too Many Requests" },
Expand All @@ -65,7 +72,10 @@ static constexpr struct {
{ HttpStatus::GATEWAY_TIMEOUT, "504 Gateway Timeout" },
{ HttpStatus::HTTP_VERSION_NOT_SUPPORTED,
"505 HTTP Version Not Supported" },
{ HttpStatus::VARIANT_ALSO_NEGOTIATES, "506 Variant Also Negotiates" },
{ HttpStatus::INSUFFICIENT_STORAGE, "507 Insufficient Storage" },
{ HttpStatus::LOOP_DETECTED, "508 Loop Detected"},
{ HttpStatus::NOT_EXTENDED, "510 Not Extended"},
{ HttpStatus::NETWORK_AUTHENTICATION_REQUIRED,
"511 Network Authentication Required" },
};
Expand Down
44 changes: 43 additions & 1 deletion src/http/Status.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ enum class HttpStatus : uint_least16_t {
CONTINUE = 100,
SWITCHING_PROTOCOLS = 101,

// added in RFC 2518, removed in RFC 4918 (WebDAV)
PROCESSING = 102,

// added in RFC 2518, removed in RFC 4918 (WebDAV)
EARLY_HINTS = 103,

OK = 200,
CREATED = 201,
ACCEPTED = 202,
Expand All @@ -32,13 +38,24 @@ enum class HttpStatus : uint_least16_t {
*/
MULTI_STATUS = 207,

/**
* @see RFC 5842 (Binding Extensiosn to WebDAV)
*/
ALREADY_REPORTED = 208,

/**
* @see RFC 3229 (Delta Encoding in HTTP)
*/
IM_USED = 226,

MULTIPLE_CHOICES = 300,
MOVED_PERMANENTLY = 301,
FOUND = 302,
SEE_OTHER = 303,
NOT_MODIFIED = 304,
USE_PROXY = 305,
USE_PROXY = 305, // deprecated in RFC 7231
TEMPORARY_REDIRECT = 307,
PERMANENT_REDIRECT = 308, // RFC 9110 (HTTP Semantics)
BAD_REQUEST = 400,
UNAUTHORIZED = 401,
PAYMENT_REQUIRED = 402,
Expand All @@ -63,6 +80,11 @@ enum class HttpStatus : uint_least16_t {
*/
I_M_A_TEAPOT = 418,

/**
* @see RFC 9110 (HTTP Semantics)
*/
MISDIRECTED_REQUEST = 421,

/**
* @see RFC 4918 (WebDAV)
*/
Expand All @@ -78,6 +100,11 @@ enum class HttpStatus : uint_least16_t {
*/
FAILED_DEPENDENCY = 424,

/**
* @see RFC 8470 (Using Early Data in HTTP)
*/
TOO_EARLY = 425,

/**
* @see RFC 7231 (HTTP 1.1)
*/
Expand Down Expand Up @@ -110,11 +137,26 @@ enum class HttpStatus : uint_least16_t {
GATEWAY_TIMEOUT = 504,
HTTP_VERSION_NOT_SUPPORTED = 505,

/**
* @see RFC 2295 (Transparent Content Negotiation in HTTP)
*/
VARIANT_ALSO_NEGOTIATES = 506,

/**
* @see RFC 4918 (WebDAV)
*/
INSUFFICIENT_STORAGE = 507,

/**
* @see RFC 5842 (Binding Extensions to WebDAV)
*/
LOOP_DETECTED = 508,

/**
* @see RFC 2774 (An HTTP Extension Framework)
*/
NOT_EXTENDED = 510,

/**
* @see RFC 6585 (Additional HTTP Status Codes)
*/
Expand Down

0 comments on commit 1c43fd0

Please sign in to comment.