<div>Hello!</div><div><br></div>It add a few of new http status code In RFC 6585(<a href="http://tools.ietf.org/html/rfc6585">http://tools.ietf.org/html/rfc6585</a>), and so I add this to Nginx.<div><br></div><div>The new http status code 429(<span style="font-size:1em">Too Many Requests)</span> and 431(<span style="font-size:1em">Request Header Fields Too Large)</span>  in RFC 6585 is useful to Nginx, </div>

<div>because Nginx will return 400 when request header is Too Large and return 503 when too many request(in limit_req).</div><div><br></div><div><div>Blew is patch(for Nginx trunk) to use 429 <font face="arial, helvetica, sans-serif"><span style="font-size:13px;white-space:nowrap">replace 400 when request header is too large, </span></font></div>

<div><span style="font-family:arial,helvetica,sans-serif;font-size:13px;white-space:nowrap">and use 431 replace 503 when find too many request(limit_req module). </span><span style="font-family:arial,helvetica,sans-serif;font-size:13px;white-space:nowrap">in addition to add new http status code 511.</span></div>

<div><span style="font-family:'Microsoft YaHei';font-size:13px;white-space:nowrap"><br></span></div><div><span style="font-size:13px;white-space:nowrap"><font face="arial, helvetica, sans-serif">Thanks</font></span><span style="font-family:'Microsoft YaHei';font-size:13px;white-space:nowrap">!</span></div>

<div><br></div><div><div><div>Index: src/http/ngx_http_special_response.c</div><div>===================================================================</div><div>--- src/http/ngx_http_special_response.c<span class="Apple-tab-span" style="white-space:pre">   </span>(revision 4615)</div>

<div>+++ src/http/ngx_http_special_response.c<span class="Apple-tab-span" style="white-space:pre">      </span>(working copy)</div><div>@@ -210,13 +210,21 @@</div><div> ;</div><div> </div><div> </div><div>-static char ngx_http_error_494_page[] =</div>

<div>+static char ngx_http_error_429_page[] =</div><div> "<html>" CRLF</div><div>-"<head><title>400 Request Header Or Cookie Too Large</title></head>"</div><div>+"<head><title>429 Too Many Requests</title></head>" CRLF</div>

<div>+"<body bgcolor=\"white\">" CRLF</div><div>+"<center><h1>429 Too Many Requests</h1></center>" CRLF</div><div>+;</div><div>+</div><div>+</div><div>+static char ngx_http_error_431_page[] =</div>

<div>+"<html>" CRLF</div><div>+"<head><title>431 Request Header Fields Too Large</title></head>"</div><div> CRLF</div><div> "<body bgcolor=\"white\">" CRLF</div>

<div>-"<center><h1>400 Bad Request</h1></center>" CRLF</div><div>-"<center>Request Header Or Cookie Too Large</center>" CRLF</div><div>+"<h1>431 Request Header Fields Too Large</h1>" CRLF</div>

<div>+"<p>request header fields too large."</div><div> ;</div><div> </div><div> </div><div>@@ -298,6 +306,16 @@</div><div> ;</div><div> </div><div> </div><div>+static char ngx_http_error_511_page[] =</div>

<div>+"<html>" CRLF</div><div>+"<head><title>511 Network Authentication Required</title></head>" CRLF</div><div>+"<body bgcolor=\"white\">" CRLF</div>

<div>+"<center><h1>511 Network Authentication Required</h1></center>" CRLF</div><div>+"<p>You need to "</div><div>+"authenticate with the local network in order to gain access."</div>

<div>+;</div><div>+</div><div>+</div><div> static ngx_str_t ngx_http_error_pages[] = {</div><div> </div><div>     ngx_null_string,                     /* 201, 204 */</div><div>@@ -334,11 +352,25 @@</div><div>     ngx_string(ngx_http_error_414_page),</div>

<div>     ngx_string(ngx_http_error_415_page),</div><div>     ngx_string(ngx_http_error_416_page),</div><div>+    ngx_null_string,                     /* 417 */</div><div>+    ngx_null_string,                     /* 418 */</div>

<div>+    ngx_null_string,                     /* 419 */</div><div>+    ngx_null_string,                     /* 420 */</div><div>+    ngx_null_string,                     /* 421 */</div><div>+    ngx_null_string,                     /* 422 */</div>

<div>+    ngx_null_string,                     /* 423 */</div><div>+    ngx_null_string,                     /* 424 */</div><div>+    ngx_null_string,                     /* 425 */</div><div>+    ngx_null_string,                     /* 426 */</div>

<div>+    ngx_null_string,                     /* 427 */</div><div>+    ngx_null_string,                     /* 428 */</div><div>+    ngx_string(ngx_http_error_429_page),</div><div>+    ngx_null_string,                     /* 430 */</div>

<div>+    ngx_string(ngx_http_error_431_page),</div><div> </div><div>-#define NGX_HTTP_LAST_4XX  417</div><div>+#define NGX_HTTP_LAST_4XX  432</div><div> #define NGX_HTTP_OFF_5XX   (NGX_HTTP_LAST_4XX - 400 + NGX_HTTP_OFF_4XX)</div>

<div> </div><div>-    ngx_string(ngx_http_error_494_page), /* 494, request header too large */</div><div>     ngx_string(ngx_http_error_495_page), /* 495, https certificate error */</div><div>     ngx_string(ngx_http_error_496_page), /* 496, https no certificate */</div>

<div>     ngx_string(ngx_http_error_497_page), /* 497, http to https */</div><div>@@ -352,9 +384,13 @@</div><div>     ngx_string(ngx_http_error_504_page),</div><div>     ngx_null_string,                     /* 505 */</div>

<div>     ngx_null_string,                     /* 506 */</div><div>-    ngx_string(ngx_http_error_507_page)</div><div>+    ngx_string(ngx_http_error_507_page),</div><div>+    ngx_null_string,                     /* 508 */</div>

<div>+    ngx_null_string,                     /* 509 */</div><div>+    ngx_null_string,                     /* 510 */</div><div>+    ngx_string(ngx_http_error_511_page),</div><div> </div><div>-#define NGX_HTTP_LAST_5XX  508</div>

<div>+#define NGX_HTTP_LAST_5XX  512</div><div> </div><div> };</div><div> </div><div>@@ -460,7 +496,6 @@</div><div>             case NGX_HTTP_TO_HTTPS:</div><div>             case NGX_HTTPS_CERT_ERROR:</div><div>             case NGX_HTTPS_NO_CERT:</div>

<div>-            case NGX_HTTP_REQUEST_HEADER_TOO_LARGE:</div><div>                 r->err_status = NGX_HTTP_BAD_REQUEST;</div><div>                 break;</div><div>         }</div><div>Index: src/http/modules/ngx_http_limit_req_module.c</div>

<div>===================================================================</div><div>--- src/http/modules/ngx_http_limit_req_module.c<span class="Apple-tab-span" style="white-space:pre">    </span>(revision 4615)</div><div>+++ src/http/modules/ngx_http_limit_req_module.c<span class="Apple-tab-span" style="white-space:pre">      </span>(working copy)</div>

<div>@@ -245,7 +245,7 @@</div><div>             ctx->node = NULL;</div><div>         }</div><div> </div><div>-        return NGX_HTTP_SERVICE_UNAVAILABLE;</div><div>+        return NGX_HTTP_TOO_MANY_REQUESTS;</div><div>

     }</div><div> </div><div>     /* rc == NGX_AGAIN || rc == NGX_OK */</div><div>Index: src/http/ngx_http_request.h</div><div>===================================================================</div><div>--- src/http/ngx_http_request.h<span class="Apple-tab-span" style="white-space:pre">  </span>(revision 4615)</div>

<div>+++ src/http/ngx_http_request.h<span class="Apple-tab-span" style="white-space:pre">       </span>(working copy)</div><div>@@ -91,16 +91,18 @@</div><div> #define NGX_HTTP_UNSUPPORTED_MEDIA_TYPE    415</div><div> #define NGX_HTTP_RANGE_NOT_SATISFIABLE     416</div>

<div> </div><div>+/* RFC 6585 */</div><div>+#define NGX_HTTP_TOO_MANY_REQUESTS         429</div><div>+#define NGX_HTTP_REQUEST_HEADER_TOO_LARGE  431</div><div> </div><div>+</div><div> /* Our own HTTP codes */</div><div> </div>

<div> /* The special code to close connection without any response */</div><div> #define NGX_HTTP_CLOSE                     444</div><div> </div><div>-#define NGX_HTTP_NGINX_CODES               494</div><div>+#define NGX_HTTP_NGINX_CODES               495</div>

<div> </div><div>-#define NGX_HTTP_REQUEST_HEADER_TOO_LARGE  494</div><div>-</div><div> #define NGX_HTTPS_CERT_ERROR               495</div><div> #define NGX_HTTPS_NO_CERT                  496</div><div> </div><div>@@ -128,7 +130,10 @@</div>

<div> #define NGX_HTTP_GATEWAY_TIME_OUT          504</div><div> #define NGX_HTTP_INSUFFICIENT_STORAGE      507</div><div> </div><div>+/* RFC 6585 */</div><div>+#define NGX_HTTP_NETWORK_AUTHENTICATION_REQUIRED      511</div>

<div> </div><div>+</div><div> #define NGX_HTTP_LOWLEVEL_BUFFERED         0xf0</div><div> #define NGX_HTTP_WRITE_BUFFERED            0x10</div><div> #define NGX_HTTP_GZIP_BUFFERED             0x20</div><div>Index: src/http/ngx_http_header_filter_module.c</div>

<div>===================================================================</div><div>--- src/http/ngx_http_header_filter_module.c<span class="Apple-tab-span" style="white-space:pre">        </span>(revision 4615)</div><div>+++ src/http/ngx_http_header_filter_module.c<span class="Apple-tab-span" style="white-space:pre">  </span>(working copy)</div>

<div>@@ -99,16 +99,24 @@</div><div>     ngx_string("415 Unsupported Media Type"),</div><div>     ngx_string("416 Requested Range Not Satisfiable"),</div><div> </div><div>-    /* ngx_null_string, */  /* "417 Expectation Failed" */</div>

<div>-    /* ngx_null_string, */  /* "418 unused" */</div><div>-    /* ngx_null_string, */  /* "419 unused" */</div><div>-    /* ngx_null_string, */  /* "420 unused" */</div><div>-    /* ngx_null_string, */  /* "421 unused" */</div>

<div>-    /* ngx_null_string, */  /* "422 Unprocessable Entity" */</div><div>-    /* ngx_null_string, */  /* "423 Locked" */</div><div>-    /* ngx_null_string, */  /* "424 Failed Dependency" */</div>

<div>+    ngx_null_string,  /* "417 Expectation Failed" */</div><div>+    ngx_null_string,  /* "418 unused" */</div><div>+    ngx_null_string,  /* "419 unused" */</div><div>+    ngx_null_string,  /* "420 unused" */</div>

<div>+    ngx_null_string,  /* "421 unused" */</div><div>+    ngx_null_string,  /* "422 Unprocessable Entity" */</div><div>+    ngx_null_string,  /* "423 Locked" */</div><div>+    ngx_null_string,  /* "424 Failed Dependency" */</div>

<div>+    ngx_null_string,  /* "425 unused" */</div><div>+    ngx_null_string,  /* "426 unused" */</div><div>+    ngx_null_string,  /* "427 unused" */</div><div>+    ngx_null_string,  /* "428 Precondition Required" */</div>

<div> </div><div>-#define NGX_HTTP_LAST_4XX  417</div><div>+    ngx_string("429 Too Many Requests"),</div><div>+    ngx_null_string,  /* "430 unused" */</div><div>+    ngx_string("431 Request Header Fields Too Large"),</div>

<div>+</div><div>+#define NGX_HTTP_LAST_4XX  432</div><div> #define NGX_HTTP_OFF_5XX   (NGX_HTTP_LAST_4XX - 400 + NGX_HTTP_OFF_4XX)</div><div> </div><div>     ngx_string("500 Internal Server Error"),</div><div>
@@ -120,12 +128,14 @@</div>
<div>     ngx_null_string,        /* "505 HTTP Version Not Supported" */</div><div>     ngx_null_string,        /* "506 Variant Also Negotiates" */</div><div>     ngx_string("507 Insufficient Storage"),</div>

<div>-    /* ngx_null_string, */  /* "508 unused" */</div><div>-    /* ngx_null_string, */  /* "509 unused" */</div><div>-    /* ngx_null_string, */  /* "510 Not Extended" */</div><div>+    ngx_null_string,        /* "508 unused" */</div>

<div>+    ngx_null_string,        /* "509 unused" */</div><div>+    ngx_null_string,        /* "510 Not Extended" */</div><div> </div><div>-#define NGX_HTTP_LAST_5XX  508</div><div>+    ngx_string("511 Network Authentication Required"),</div>

<div> </div><div>+#define NGX_HTTP_LAST_5XX  512</div><div>+</div><div> };</div><div> </div><div> </div></div><div><br></div><div><br></div><div><br></div>-- <br><div><span style="color:rgb(102,102,102);font-family:Arial,Helvetica,sans-serif;font-size:12px;line-height:18px;background-color:rgb(255,246,237)">do not fear to be eccentric in opinion, for every opinion now accepted was once eccentric. </span></div>

<br>
</div></div>