mirror of
https://github.com/nginx/nginx.git
synced 2024-12-19 05:33:52 -06:00
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).
This commit is contained in:
parent
a38402e306
commit
51f714c85d
@ -534,15 +534,24 @@ ngx_http_upstream_init_request(ngx_http_request_t *r)
|
|||||||
|
|
||||||
r->write_event_handler = ngx_http_request_empty_handler;
|
r->write_event_handler = ngx_http_request_empty_handler;
|
||||||
|
|
||||||
if (rc == NGX_DONE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rc == NGX_ERROR) {
|
if (rc == NGX_ERROR) {
|
||||||
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||||
return;
|
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) {
|
if (rc != NGX_DECLINED) {
|
||||||
ngx_http_finalize_request(r, rc);
|
ngx_http_finalize_request(r, rc);
|
||||||
return;
|
return;
|
||||||
@ -837,13 +846,7 @@ ngx_http_upstream_cache(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
|||||||
|
|
||||||
case NGX_OK:
|
case NGX_OK:
|
||||||
|
|
||||||
rc = ngx_http_upstream_cache_send(r, u);
|
return NGX_OK;
|
||||||
|
|
||||||
if (rc != NGX_HTTP_UPSTREAM_INVALID_HEADER) {
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NGX_HTTP_CACHE_STALE:
|
case NGX_HTTP_CACHE_STALE:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user