[nginx] svn commit: r4936 - trunk/src/http
mdounin at mdounin.ru
mdounin at mdounin.ru
Mon Nov 26 18:00:15 UTC 2012
Author: mdounin
Date: 2012-11-26 18:00:14 +0000 (Mon, 26 Nov 2012)
New Revision: 4936
URL: http://trac.nginx.org/nginx/changeset/4936/nginx
Log:
Request body: improved handling of incorrect chunked request body.
While discarding chunked request body in some cases after detecting
request body corruption no error was returned, while it was possible
to correctly return 400 Bad Request. If error is detected too late,
make sure to properly close connection.
Additionally, in ngx_http_special_response_handler() don't return body
of 500 Internal Server Error to a client if ngx_http_discard_request_body()
fails, but disable keepalive and continue.
Modified:
trunk/src/http/ngx_http_request_body.c
trunk/src/http/ngx_http_special_response.c
Modified: trunk/src/http/ngx_http_request_body.c
===================================================================
--- trunk/src/http/ngx_http_request_body.c 2012-11-26 17:59:30 UTC (rev 4935)
+++ trunk/src/http/ngx_http_request_body.c 2012-11-26 18:00:14 UTC (rev 4936)
@@ -471,13 +471,19 @@
}
}
- if (ngx_http_read_discarded_request_body(r) == NGX_OK) {
+ rc = ngx_http_read_discarded_request_body(r);
+
+ if (rc == NGX_OK) {
r->lingering_close = 0;
return NGX_OK;
}
- /* == NGX_AGAIN */
+ if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
+ return rc;
+ }
+ /* rc == NGX_AGAIN */
+
r->read_event_handler = ngx_http_discarded_request_body_handler;
if (ngx_handle_read_event(rev, 0) != NGX_OK) {
@@ -533,6 +539,12 @@
return;
}
+ if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
+ c->error = 1;
+ ngx_http_finalize_request(r, NGX_ERROR);
+ return;
+ }
+
/* rc == NGX_AGAIN */
if (ngx_handle_read_event(rev, 0) != NGX_OK) {
@@ -606,8 +618,7 @@
rc = ngx_http_discard_request_body_filter(r, &b);
if (rc != NGX_OK) {
- r->connection->error = 1;
- return NGX_OK;
+ return rc;
}
}
}
Modified: trunk/src/http/ngx_http_special_response.c
===================================================================
--- trunk/src/http/ngx_http_special_response.c 2012-11-26 17:59:30 UTC (rev 4935)
+++ trunk/src/http/ngx_http_special_response.c 2012-11-26 18:00:14 UTC (rev 4936)
@@ -421,7 +421,7 @@
r->expect_tested = 1;
if (ngx_http_discard_request_body(r) != NGX_OK) {
- error = NGX_HTTP_INTERNAL_SERVER_ERROR;
+ r->keepalive = 0;
}
if (clcf->msie_refresh
More information about the nginx-devel
mailing list