aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_upstream.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/ngx_http_upstream.c')
-rw-r--r--src/http/ngx_http_upstream.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index cca417d96..fb3209270 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -1077,6 +1077,10 @@ ngx_http_upstream_cache_background_update(ngx_http_request_t *r,
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 @@ ngx_http_upstream_send_response(ngx_http_request_t *r, ngx_http_upstream_t *u)
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;
}