diff --git a/include/httpd.h b/include/httpd.h index 343a98d755..f9883b9771 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -472,11 +472,12 @@ AP_DECLARE(const char *) ap_get_server_built(void); * @{ */ /** - * The size of the static array in http_protocol.c for storing - * all of the potential response status-lines (a sparse table). + * The size of the static status_lines array in http_protocol.c for + * storing all of the potential response status-lines (a sparse table). + * When adding a new code here add it to status_lines as well. * A future version should dynamically generate the apr_table_t at startup. */ -#define RESPONSE_CODES 57 +#define RESPONSE_CODES 83 #define HTTP_CONTINUE 100 #define HTTP_SWITCHING_PROTOCOLS 101 @@ -489,6 +490,8 @@ AP_DECLARE(const char *) ap_get_server_built(void); #define HTTP_RESET_CONTENT 205 #define HTTP_PARTIAL_CONTENT 206 #define HTTP_MULTI_STATUS 207 +#define HTTP_ALREADY_REPORTED 208 +#define HTTP_IM_USED 226 #define HTTP_MULTIPLE_CHOICES 300 #define HTTP_MOVED_PERMANENTLY 301 #define HTTP_MOVED_TEMPORARILY 302 @@ -496,6 +499,7 @@ AP_DECLARE(const char *) ap_get_server_built(void); #define HTTP_NOT_MODIFIED 304 #define HTTP_USE_PROXY 305 #define HTTP_TEMPORARY_REDIRECT 307 +#define HTTP_PERMANENT_REDIRECT 308 #define HTTP_BAD_REQUEST 400 #define HTTP_UNAUTHORIZED 401 #define HTTP_PAYMENT_REQUIRED 402 @@ -518,6 +522,9 @@ AP_DECLARE(const char *) ap_get_server_built(void); #define HTTP_LOCKED 423 #define HTTP_FAILED_DEPENDENCY 424 #define HTTP_UPGRADE_REQUIRED 426 +#define HTTP_PRECONDITION_REQUIRED 428 +#define HTTP_TOO_MANY_REQUESTS 429 +#define HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE 431 #define HTTP_INTERNAL_SERVER_ERROR 500 #define HTTP_NOT_IMPLEMENTED 501 #define HTTP_BAD_GATEWAY 502 @@ -526,7 +533,9 @@ AP_DECLARE(const char *) ap_get_server_built(void); #define HTTP_VERSION_NOT_SUPPORTED 505 #define HTTP_VARIANT_ALSO_VARIES 506 #define HTTP_INSUFFICIENT_STORAGE 507 +#define HTTP_LOOP_DETECTED 508 #define HTTP_NOT_EXTENDED 510 +#define HTTP_NETWORK_AUTHENTICATION_REQUIRED 511 /** is the status code informational */ #define ap_is_HTTP_INFO(x) (((x) >= 100)&&((x) < 200)) diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index 10165478b5..7cbe769a87 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -62,8 +62,12 @@ APLOG_USE_MODULE(http); /* New Apache routine to map status codes into array indicies * e.g. 100 -> 0, 101 -> 1, 200 -> 2 ... - * The number of status lines must equal the value of RESPONSE_CODES (httpd.h) - * and must be listed in order. + * The number of status lines must equal the value of + * RESPONSE_CODES (httpd.h) and must be listed in order. + * No gaps are allowed between X00 and the largest Xnn + * for any X (see ap_index_of_response). + * When adding a new code here, add a define to httpd.h + * as well. */ static const char * const status_lines[RESPONSE_CODES] = @@ -80,58 +84,81 @@ static const char * const status_lines[RESPONSE_CODES] = "205 Reset Content", "206 Partial Content", "207 Multi-Status", -#define LEVEL_300 11 + "208 Already Reported", + NULL, /* 209 */ + NULL, /* 210 */ + NULL, /* 211 */ + NULL, /* 212 */ + NULL, /* 213 */ + NULL, /* 214 */ + NULL, /* 215 */ + NULL, /* 216 */ + NULL, /* 217 */ + NULL, /* 218 */ + NULL, /* 219 */ + NULL, /* 220 */ + NULL, /* 221 */ + NULL, /* 222 */ + NULL, /* 223 */ + NULL, /* 224 */ + NULL, /* 225 */ + "226 IM Used", +#define LEVEL_300 30 "300 Multiple Choices", "301 Moved Permanently", "302 Found", "303 See Other", "304 Not Modified", "305 Use Proxy", - "306 unused", + NULL, /* 306 */ "307 Temporary Redirect", -#define LEVEL_400 19 + "308 Permanent Redirect", +#define LEVEL_400 39 "400 Bad Request", - "401 Authorization Required", + "401 Unauthorized", "402 Payment Required", "403 Forbidden", "404 Not Found", "405 Method Not Allowed", "406 Not Acceptable", "407 Proxy Authentication Required", - "408 Request Time-out", + "408 Request Timeout", "409 Conflict", "410 Gone", "411 Length Required", "412 Precondition Failed", "413 Request Entity Too Large", - "414 Request-URI Too Large", + "414 Request-URI Too Long", "415 Unsupported Media Type", "416 Requested Range Not Satisfiable", "417 Expectation Failed", - "418 unused", - "419 unused", - "420 unused", - "421 unused", + NULL, /* 418 */ + NULL, /* 419 */ + NULL, /* 420 */ + NULL, /* 421 */ "422 Unprocessable Entity", "423 Locked", "424 Failed Dependency", - /* This is a hack, but it is required for ap_index_of_response - * to work with 426. - */ - "425 No code", + NULL, /* 425 */ "426 Upgrade Required", -#define LEVEL_500 46 + NULL, /* 427 */ + "428 Precondition Required", + "429 Too Many Requests", + NULL, /* 430 */ + "431 Request Header Fields Too Large", +#define LEVEL_500 71 "500 Internal Server Error", - "501 Method Not Implemented", + "501 Not Implemented", "502 Bad Gateway", - "503 Service Temporarily Unavailable", - "504 Gateway Time-out", + "503 Service Unavailable", + "504 Gateway Timeout", "505 HTTP Version Not Supported", "506 Variant Also Negotiates", "507 Insufficient Storage", - "508 unused", - "509 unused", - "510 Not Extended" + "508 Loop Detected", + NULL, /* 509 */ + "510 Not Extended", + "511 Network Authentication Required" }; APR_HOOK_STRUCT( @@ -739,6 +766,7 @@ AP_DECLARE(const char *) ap_method_name_of(apr_pool_t *p, int methnum) * decides to define a high-numbered code before the lower numbers. * If that sad event occurs, replace the code below with a linear search * from status_lines[shortcut[i]] to status_lines[shortcut[i+1]-1]; + * or use NULL to fill the gaps. */ AP_DECLARE(int) ap_index_of_response(int status) { @@ -754,7 +782,7 @@ AP_DECLARE(int) ap_index_of_response(int status) status -= 100; if (status < 100) { pos = (status + shortcut[i]); - if (pos < shortcut[i + 1]) { + if (pos < shortcut[i + 1] && status_lines[pos] != NULL) { return pos; } else { @@ -887,6 +915,7 @@ static const char *get_canned_error_string(int status, case HTTP_MOVED_PERMANENTLY: case HTTP_MOVED_TEMPORARILY: case HTTP_TEMPORARY_REDIRECT: + case HTTP_PERMANENT_REDIRECT: return(apr_pstrcat(p, "