Mercurial > hg > nginx
diff src/http/ngx_http_upstream.c @ 7070:f583559aadc7
Upstream: keep request body file from removal if requested.
The new request flag "preserve_body" indicates that the request body file should
not be removed by the upstream module because it may be used later by a
subrequest. The flag is set by the SSI (ticket #585), addition and slice
modules. Additionally, it is also set by the upstream module when a background
cache update subrequest is started to prevent the request body file removal
after an internal redirect. Only the main request is now allowed to remove the
file.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Wed, 19 Jul 2017 20:38:17 +0300 |
parents | e3723f2a11b7 |
children | 2a288909abc6 |
line wrap: on
line diff
--- a/src/http/ngx_http_upstream.c Wed Jul 19 21:39:40 2017 +0800 +++ b/src/http/ngx_http_upstream.c Wed Jul 19 20:38:17 2017 +0300 @@ -1077,6 +1077,10 @@ return NGX_OK; } + if (r == r->main) { + r->preserve_body = 1; + } + if (ngx_http_subrequest(r, &r->uri, &r->args, &sr, NULL, NGX_HTTP_SUBREQUEST_CLONE |NGX_HTTP_SUBREQUEST_BACKGROUND) @@ -2857,7 +2861,9 @@ u->pipe->downstream_error = 1; } - if (r->request_body && r->request_body->temp_file) { + if (r->request_body && r->request_body->temp_file + && r == r->main && !r->preserve_body) + { ngx_pool_run_cleanup_file(r->pool, r->request_body->temp_file->file.fd); r->request_body->temp_file->file.fd = NGX_INVALID_FILE; }