comparison src/http/ngx_http_upstream.c @ 3917:2a70484a6580

fix a broken cached response if bypass/no_cache directive values are different, the bug has been introduced in r3700
author Igor Sysoev <igor@sysoev.ru>
date Fri, 13 May 2011 10:05:38 +0000
parents bd1222fb0192
children b4b7bb829fe2
comparison
equal deleted inserted replaced
3916:0ec738f18346 3917:2a70484a6580
639 639
640 c = r->cache; 640 c = r->cache;
641 641
642 if (c == NULL) { 642 if (c == NULL) {
643 643
644 if (!(r->method & u->conf->cache_methods)) {
645 return NGX_DECLINED;
646 }
647
648 if (r->method & NGX_HTTP_HEAD) {
649 u->method = ngx_http_core_get_method;
650 }
651
652 if (ngx_http_file_cache_new(r) != NGX_OK) {
653 return NGX_ERROR;
654 }
655
656 if (u->create_key(r) != NGX_OK) {
657 return NGX_ERROR;
658 }
659
660 /* TODO: add keys */
661
662 ngx_http_file_cache_create_key(r);
663
644 switch (ngx_http_test_predicates(r, u->conf->cache_bypass)) { 664 switch (ngx_http_test_predicates(r, u->conf->cache_bypass)) {
645 665
646 case NGX_ERROR: 666 case NGX_ERROR:
647 return NGX_ERROR; 667 return NGX_ERROR;
648 668
651 return NGX_DECLINED; 671 return NGX_DECLINED;
652 672
653 default: /* NGX_OK */ 673 default: /* NGX_OK */
654 break; 674 break;
655 } 675 }
656
657 if (!(r->method & u->conf->cache_methods)) {
658 return NGX_DECLINED;
659 }
660
661 if (r->method & NGX_HTTP_HEAD) {
662 u->method = ngx_http_core_get_method;
663 }
664
665 if (ngx_http_file_cache_new(r) != NGX_OK) {
666 return NGX_ERROR;
667 }
668
669 if (u->create_key(r) != NGX_OK) {
670 return NGX_ERROR;
671 }
672
673 /* TODO: add keys */
674
675 ngx_http_file_cache_create_key(r);
676 676
677 u->cacheable = 1; 677 u->cacheable = 1;
678 678
679 c = r->cache; 679 c = r->cache;
680 680
2133 2133
2134 default: /* NGX_OK */ 2134 default: /* NGX_OK */
2135 2135
2136 if (u->cache_status == NGX_HTTP_CACHE_BYPASS) { 2136 if (u->cache_status == NGX_HTTP_CACHE_BYPASS) {
2137 2137
2138 if (ngx_http_file_cache_new(r) != NGX_OK) {
2139 ngx_http_upstream_finalize_request(r, u, 0);
2140 return;
2141 }
2142
2143 if (u->create_key(r) != NGX_OK) {
2144 ngx_http_upstream_finalize_request(r, u, 0);
2145 return;
2146 }
2147
2148 /* TODO: add keys */
2149
2150 r->cache->min_uses = u->conf->cache_min_uses; 2138 r->cache->min_uses = u->conf->cache_min_uses;
2151 r->cache->body_start = u->conf->buffer_size; 2139 r->cache->body_start = u->conf->buffer_size;
2152 r->cache->file_cache = u->conf->cache->data; 2140 r->cache->file_cache = u->conf->cache->data;
2153 2141
2154 if (ngx_http_file_cache_create(r) != NGX_OK) { 2142 if (ngx_http_file_cache_create(r) != NGX_OK) {