[nginx] Request body: moved request body writing to save filter.

Maxim Dounin mdounin at mdounin.ru
Mon Mar 23 18:11:21 UTC 2015


details:   http://hg.nginx.org/nginx/rev/9e231d4cecca
branches:  
changeset: 6048:9e231d4cecca
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Mon Mar 23 21:09:19 2015 +0300
description:
Request body: moved request body writing to save filter.

diffstat:

 src/http/ngx_http_request_body.c |  22 ++++++++--------------
 1 files changed, 8 insertions(+), 14 deletions(-)

diffs (38 lines):

diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c
--- a/src/http/ngx_http_request_body.c
+++ b/src/http/ngx_http_request_body.c
@@ -277,20 +277,6 @@ ngx_http_do_read_client_request_body(ngx
                     return rc;
                 }
 
-                /* write to file */
-
-                if (ngx_http_write_request_body(r) != NGX_OK) {
-                    return NGX_HTTP_INTERNAL_SERVER_ERROR;
-                }
-
-                /* update chains */
-
-                rc = ngx_http_request_body_filter(r, NULL);
-
-                if (rc != NGX_OK) {
-                    return rc;
-                }
-
                 if (rb->busy != NULL) {
                     return NGX_HTTP_INTERNAL_SERVER_ERROR;
                 }
@@ -1100,5 +1086,13 @@ ngx_http_request_body_save_filter(ngx_ht
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
 
+    if (rb->rest > 0
+        && rb->buf && rb->buf->last == rb->buf->end)
+    {
+        if (ngx_http_write_request_body(r) != NGX_OK) {
+            return NGX_HTTP_INTERNAL_SERVER_ERROR;
+        }
+    }
+
     return NGX_OK;
 }



More information about the nginx-devel mailing list