httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rj...@apache.org
Subject svn commit: r1361784 - in /httpd/httpd/trunk: include/httpd.h modules/http/http_protocol.c modules/lua/lua_vmprep.c
Date Sun, 15 Jul 2012 20:22:03 GMT
Author: rjung
Date: Sun Jul 15 20:22:03 2012
New Revision: 1361784

URL: http://svn.apache.org/viewvc?rev=1361784&view=rev
Log:
Add missing HTTP status codes taken from

http://www.iana.org/assignments/http-status-codes/http-status-codes.xml 

The new codes are now known and some canned error
strings are provided. The web server does not yet actually
produce them in responses or reacts on getting them
from an origin server when acting as a proxy or gateway.

Modified:
    httpd/httpd/trunk/include/httpd.h
    httpd/httpd/trunk/modules/http/http_protocol.c
    httpd/httpd/trunk/modules/lua/lua_vmprep.c

Modified: httpd/httpd/trunk/include/httpd.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/httpd.h?rev=1361784&r1=1361783&r2=1361784&view=diff
==============================================================================
--- httpd/httpd/trunk/include/httpd.h (original)
+++ httpd/httpd/trunk/include/httpd.h Sun Jul 15 20:22:03 2012
@@ -472,11 +472,12 @@ AP_DECLARE(const char *) ap_get_server_b
  * @{
  */
 /**
- * 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_b
 #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_b
 #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_b
 #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_b
 #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))

Modified: httpd/httpd/trunk/modules/http/http_protocol.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http/http_protocol.c?rev=1361784&r1=1361783&r2=1361784&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http/http_protocol.c (original)
+++ httpd/httpd/trunk/modules/http/http_protocol.c Sun Jul 15 20:22:03 2012
@@ -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[R
     "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_
  * 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 -= 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_stri
     case HTTP_MOVED_PERMANENTLY:
     case HTTP_MOVED_TEMPORARILY:
     case HTTP_TEMPORARY_REDIRECT:
+    case HTTP_PERMANENT_REDIRECT:
         return(apr_pstrcat(p,
                            "<p>The document has moved <a href=\"",
                            ap_escape_html(r->pool, location),
@@ -1048,6 +1077,14 @@ static const char *get_canned_error_stri
                "connection to SSL, but your client doesn't support it.\n"
                "Either upgrade your client, or try requesting the page\n"
                "using https://\n");
+    case HTTP_PRECONDITION_REQUIRED:
+        return("<p>The request is required to be conditional.</p>\n");
+    case HTTP_TOO_MANY_REQUESTS:
+        return("<p>The user has sent too many requests\n"
+               "in a given amount of time.</p>\n");
+    case HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE:
+        return("<p>The server refused this request because\n"
+               "the request header fields are too large.</p>\n");
     case HTTP_INSUFFICIENT_STORAGE:
         return("<p>The method could not be performed on the resource\n"
                "because the server is unable to store the\n"
@@ -1061,9 +1098,15 @@ static const char *get_canned_error_stri
     case HTTP_GATEWAY_TIME_OUT:
         return("<p>The gateway did not receive a timely response\n"
                "from the upstream server or application.</p>\n");
+    case HTTP_LOOP_DETECTED:
+        return("<p>The server terminated an operation because\n"
+               "it encountered an infinite loop.</p>\n");
     case HTTP_NOT_EXTENDED:
         return("<p>A mandatory extension policy in the request is not\n"
                "accepted by the server for this resource.</p>\n");
+    case HTTP_NETWORK_AUTHENTICATION_REQUIRED:
+        return("<p>The client needs to authenticate to gain\n"
+               "network access.</p>\n");
     default:                    /* HTTP_INTERNAL_SERVER_ERROR */
         /*
          * This comparison to expose error-notes could be modified to

Modified: httpd/httpd/trunk/modules/lua/lua_vmprep.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/lua_vmprep.c?rev=1361784&r1=1361783&r2=1361784&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/lua_vmprep.c (original)
+++ httpd/httpd/trunk/modules/lua/lua_vmprep.c Sun Jul 15 20:22:03 2012
@@ -140,12 +140,16 @@ AP_LUA_DECLARE(void) ap_lua_load_apache2
        makeintegerfield(L, HTTP_RESET_CONTENT);
        makeintegerfield(L, HTTP_PARTIAL_CONTENT);
        makeintegerfield(L, HTTP_MULTI_STATUS);
+       makeintegerfield(L, HTTP_ALREADY_REPORTED);
+       makeintegerfield(L, HTTP_IM_USED);
        makeintegerfield(L, HTTP_MULTIPLE_CHOICES);
        makeintegerfield(L, HTTP_MOVED_PERMANENTLY);
+       makeintegerfield(L, HTTP_MOVED_TEMPORARILY);
        makeintegerfield(L, HTTP_SEE_OTHER);
        makeintegerfield(L, HTTP_NOT_MODIFIED);
        makeintegerfield(L, HTTP_USE_PROXY);
        makeintegerfield(L, HTTP_TEMPORARY_REDIRECT);
+       makeintegerfield(L, HTTP_PERMANENT_REDIRECT);
        makeintegerfield(L, HTTP_BAD_REQUEST);
        makeintegerfield(L, HTTP_UNAUTHORIZED);
        makeintegerfield(L, HTTP_PAYMENT_REQUIRED);
@@ -168,6 +172,9 @@ AP_LUA_DECLARE(void) ap_lua_load_apache2
        makeintegerfield(L, HTTP_LOCKED);
        makeintegerfield(L, HTTP_FAILED_DEPENDENCY);
        makeintegerfield(L, HTTP_UPGRADE_REQUIRED);
+       makeintegerfield(L, HTTP_PRECONDITION_REQUIRED);
+       makeintegerfield(L, HTTP_TOO_MANY_REQUESTS);
+       makeintegerfield(L, HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE);
        makeintegerfield(L, HTTP_INTERNAL_SERVER_ERROR);
        makeintegerfield(L, HTTP_NOT_IMPLEMENTED);
        makeintegerfield(L, HTTP_BAD_GATEWAY);
@@ -176,7 +183,9 @@ AP_LUA_DECLARE(void) ap_lua_load_apache2
        makeintegerfield(L, HTTP_VERSION_NOT_SUPPORTED);
        makeintegerfield(L, HTTP_VARIANT_ALSO_VARIES);
        makeintegerfield(L, HTTP_INSUFFICIENT_STORAGE);
+       makeintegerfield(L, HTTP_LOOP_DETECTED);
        makeintegerfield(L, HTTP_NOT_EXTENDED);
+       makeintegerfield(L, HTTP_NETWORK_AUTHENTICATION_REQUIRED);
      */
 }
 



Mime
View raw message