comparison src/http/modules/ngx_http_proxy_module.c @ 2705:d040c3786239

do not pass if-... headers for cacheable responses
author Igor Sysoev <igor@sysoev.ru>
date Wed, 15 Apr 2009 11:21:12 +0000
parents b212066acf50
children f905a6ab0ca8
comparison
equal deleted inserted replaced
2704:ac1e2e199c9f 2705:d040c3786239
480 { ngx_string("Connection"), ngx_string("close") }, 480 { ngx_string("Connection"), ngx_string("close") },
481 { ngx_string("Keep-Alive"), ngx_string("") }, 481 { ngx_string("Keep-Alive"), ngx_string("") },
482 { ngx_string("Expect"), ngx_string("") }, 482 { ngx_string("Expect"), ngx_string("") },
483 { ngx_null_string, ngx_null_string } 483 { ngx_null_string, ngx_null_string }
484 }; 484 };
485
486
487 #if (NGX_HTTP_CACHE)
488
489 static ngx_keyval_t ngx_http_proxy_cache_headers[] = {
490 { ngx_string("Host"), ngx_string("$proxy_host") },
491 { ngx_string("Connection"), ngx_string("close") },
492 { ngx_string("Keep-Alive"), ngx_string("") },
493 { ngx_string("Expect"), ngx_string("") },
494 { ngx_string("If-Modified-Since"), ngx_string("") },
495 { ngx_string("If-Unmodified-Since"), ngx_string("") },
496 { ngx_string("If-Match-None"), ngx_string("") },
497 { ngx_string("If-Match"), ngx_string("") },
498 { ngx_string("Range"), ngx_string("") },
499 { ngx_string("If-Range"), ngx_string("") },
500 { ngx_null_string, ngx_null_string }
501 };
502
503 #endif
485 504
486 505
487 static ngx_str_t ngx_http_proxy_hide_headers[] = { 506 static ngx_str_t ngx_http_proxy_hide_headers[] = {
488 ngx_string("Date"), 507 ngx_string("Date"),
489 ngx_string("Server"), 508 ngx_string("Server"),
2284 } 2303 }
2285 2304
2286 2305
2287 src = conf->headers_source->elts; 2306 src = conf->headers_source->elts;
2288 2307
2289 for (h = ngx_http_proxy_headers; h->key.len; h++) { 2308 #if (NGX_HTTP_CACHE)
2309
2310 h = conf->upstream.cache ? ngx_http_proxy_cache_headers:
2311 ngx_http_proxy_headers;
2312 #else
2313
2314 h = ngx_http_proxy_headers;
2315
2316 #endif
2317
2318 while (h->key.len) {
2290 2319
2291 for (i = 0; i < conf->headers_source->nelts; i++) { 2320 for (i = 0; i < conf->headers_source->nelts; i++) {
2292 if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) { 2321 if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) {
2293 goto next; 2322 goto next;
2294 } 2323 }
2303 2332
2304 src = conf->headers_source->elts; 2333 src = conf->headers_source->elts;
2305 2334
2306 next: 2335 next:
2307 2336
2308 continue; 2337 h++;
2309 } 2338 }
2310 2339
2311 2340
2312 src = conf->headers_source->elts; 2341 src = conf->headers_source->elts;
2313 for (i = 0; i < conf->headers_source->nelts; i++) { 2342 for (i = 0; i < conf->headers_source->nelts; i++) {