diff src/http/ngx_http_request_body.c @ 6496:887cca40ba6a

HTTP/2: rewritten handling of request body. There are two improvements: 1. Support for request body filters; 2. Receiving of request body is started only after the ngx_http_read_client_request_body() call. The last one fixes the problem when the client_max_body_size value might not be respected from the right location if the location was changed either during the process of receiving body or after the whole body had been received.
author Valentin Bartenev <vbart@nginx.com>
date Fri, 01 Apr 2016 15:56:03 +0300
parents 3b9fe734a76c
children 9d66d7ed2abb
line wrap: on
line diff
--- a/src/http/ngx_http_request_body.c
+++ b/src/http/ngx_http_request_body.c
@@ -40,20 +40,20 @@ ngx_http_read_client_request_body(ngx_ht
 
     r->main->count++;
 
+    if (r != r->main || r->request_body || r->discard_body) {
+        r->request_body_no_buffering = 0;
+        post_handler(r);
+        return NGX_OK;
+    }
+
 #if (NGX_HTTP_V2)
-    if (r->stream && r == r->main) {
+    if (r->stream) {
         r->request_body_no_buffering = 0;
         rc = ngx_http_v2_read_request_body(r, post_handler);
         goto done;
     }
 #endif
 
-    if (r != r->main || r->request_body || r->discard_body) {
-        r->request_body_no_buffering = 0;
-        post_handler(r);
-        return NGX_OK;
-    }
-
     if (ngx_http_test_expect(r) != NGX_OK) {
         rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
         goto done;
@@ -503,17 +503,17 @@ ngx_http_discard_request_body(ngx_http_r
     ngx_int_t     rc;
     ngx_event_t  *rev;
 
+    if (r != r->main || r->discard_body || r->request_body) {
+        return NGX_OK;
+    }
+
 #if (NGX_HTTP_V2)
-    if (r->stream && r == r->main) {
-        r->stream->skip_data = NGX_HTTP_V2_DATA_DISCARD;
+    if (r->stream) {
+        r->stream->skip_data = 1;
         return NGX_OK;
     }
 #endif
 
-    if (r != r->main || r->discard_body || r->request_body) {
-        return NGX_OK;
-    }
-
     if (ngx_http_test_expect(r) != NGX_OK) {
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }