diff options
author | Roman Arutyunyan <arut@nginx.com> | 2015-09-03 15:09:21 +0300 |
---|---|---|
committer | Roman Arutyunyan <arut@nginx.com> | 2015-09-03 15:09:21 +0300 |
commit | 51f714c85d1554ee2a1ccfe94b416e3cab6a63ad (patch) | |
tree | 89db17f2f1f4f4c3b38c02141af194c5ef482057 | |
parent | a38402e306b1ef146b4fe2e150aaec77fecc2390 (diff) | |
download | nginx-51f714c85d1554ee2a1ccfe94b416e3cab6a63ad.tar.gz nginx-51f714c85d1554ee2a1ccfe94b416e3cab6a63ad.zip |
Upstream: fixed cache send error handling.
The value of NGX_ERROR, returned from filter handlers, was treated as a generic
upstream error and changed to NGX_HTTP_INTERNAL_SERVER_ERROR before calling
ngx_http_finalize_request(). This resulted in "header already sent" alert
if header was already sent in filter handlers.
The problem appeared in 54e9b83d00f0 (1.7.5).
-rw-r--r-- | src/http/ngx_http_upstream.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index 4b0332a42..31d5c7b1b 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -534,15 +534,24 @@ ngx_http_upstream_init_request(ngx_http_request_t *r) r->write_event_handler = ngx_http_request_empty_handler; - if (rc == NGX_DONE) { - return; - } - if (rc == NGX_ERROR) { ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); return; } + if (rc == NGX_OK) { + rc = ngx_http_upstream_cache_send(r, u); + + if (rc == NGX_DONE) { + return; + } + + if (rc == NGX_HTTP_UPSTREAM_INVALID_HEADER) { + rc = NGX_DECLINED; + r->cached = 0; + } + } + if (rc != NGX_DECLINED) { ngx_http_finalize_request(r, rc); return; @@ -837,13 +846,7 @@ ngx_http_upstream_cache(ngx_http_request_t *r, ngx_http_upstream_t *u) case NGX_OK: - rc = ngx_http_upstream_cache_send(r, u); - - if (rc != NGX_HTTP_UPSTREAM_INVALID_HEADER) { - return rc; - } - - break; + return NGX_OK; case NGX_HTTP_CACHE_STALE: |