Mercurial > hg > nginx
comparison src/http/ngx_http_upstream.c @ 6342:50169ef2f3fe stable-1.8
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).
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Thu, 03 Sep 2015 15:09:21 +0300 |
parents | 643f2ce02f1c |
children |
comparison
equal
deleted
inserted
replaced
6341:2797b4347a2a | 6342:50169ef2f3fe |
---|---|
528 return; | 528 return; |
529 } | 529 } |
530 | 530 |
531 r->write_event_handler = ngx_http_request_empty_handler; | 531 r->write_event_handler = ngx_http_request_empty_handler; |
532 | 532 |
533 if (rc == NGX_DONE) { | |
534 return; | |
535 } | |
536 | |
537 if (rc == NGX_ERROR) { | 533 if (rc == NGX_ERROR) { |
538 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | 534 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
539 return; | 535 return; |
536 } | |
537 | |
538 if (rc == NGX_OK) { | |
539 rc = ngx_http_upstream_cache_send(r, u); | |
540 | |
541 if (rc == NGX_DONE) { | |
542 return; | |
543 } | |
544 | |
545 if (rc == NGX_HTTP_UPSTREAM_INVALID_HEADER) { | |
546 rc = NGX_DECLINED; | |
547 r->cached = 0; | |
548 } | |
540 } | 549 } |
541 | 550 |
542 if (rc != NGX_DECLINED) { | 551 if (rc != NGX_DECLINED) { |
543 ngx_http_finalize_request(r, rc); | 552 ngx_http_finalize_request(r, rc); |
544 return; | 553 return; |
831 | 840 |
832 switch (rc) { | 841 switch (rc) { |
833 | 842 |
834 case NGX_OK: | 843 case NGX_OK: |
835 | 844 |
836 rc = ngx_http_upstream_cache_send(r, u); | 845 return NGX_OK; |
837 | |
838 if (rc != NGX_HTTP_UPSTREAM_INVALID_HEADER) { | |
839 return rc; | |
840 } | |
841 | |
842 break; | |
843 | 846 |
844 case NGX_HTTP_CACHE_STALE: | 847 case NGX_HTTP_CACHE_STALE: |
845 | 848 |
846 c->valid_sec = 0; | 849 c->valid_sec = 0; |
847 u->buffer.start = NULL; | 850 u->buffer.start = NULL; |