changeset 2:04788ce8dae7

Close connection on errors.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 09 Feb 2015 16:31:47 +0300
parents 17c333645ebb
children d7b8639a8857
files ngx_http_catch_body_filter_module.c t/catch_body.t
diffstat 2 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ngx_http_catch_body_filter_module.c
+++ b/ngx_http_catch_body_filter_module.c
@@ -94,6 +94,16 @@ ngx_http_catch_body_filter(ngx_http_requ
             if (*p == 'X') {
                 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                                "catch body: found");
+
+                /*
+                 * As we return NGX_HTTP_FORBIDDEN, the r->keepalive flag
+                 * won't be reset by ngx_http_special_response_handler().
+                 * Make sure to reset it to prevent processing of unread
+                 * parts of the request body.
+                 */
+
+                r->keepalive = 0;
+
                 return NGX_HTTP_FORBIDDEN;
             }
         }
--- a/t/catch_body.t
+++ b/t/catch_body.t
@@ -62,18 +62,18 @@ like(get_body('/', '123456', '12345X'),
 	'second rejected');
 
 like(get_body('/', '123456' x 1024, '12345X6789' x 1024, '123456' x 1024),
-	qr/200 OK.*403 Forbidden.*200 OK/ms,
-	'accepted rejected accepted');
+	qr/200 OK.*403 Forbidden(?!.*400 Bad)/ms,
+	'accepted rejected ignored');
 
 # pipelining with chunked
 
 like(get_chunked('/', '123456', '12345X'),
 	qr/200 OK.*403 Forbidden/ms,
-	'second rejected');
+	'chunked second rejected');
 
 like(get_chunked('/', '123456', '12345X6789', '123456'),
-	qr/200 OK.*403 Forbidden.*200 OK/ms,
-	'accepted rejected accepted');
+	qr/200 OK.*403 Forbidden(?!.*400 Bad)/ms,
+	'chunked accepted rejected ignored');
 
 ###############################################################################