diff src/http/ngx_http_upstream.c @ 484:ed5e10fb40fc NGINX_0_7_54

nginx 0.7.54 *) Feature: the ngx_http_image_filter_module. *) Feature: the "proxy_ignore_headers" and "fastcgi_ignore_headers" directives. *) Bugfix: a segmentation fault might occur in worker process, if an "open_file_cache_errors off" directive was used; the bug had appeared in 0.7.53. *) Bugfix: the "port_in_redirect off" directive did not work; the bug had appeared in 0.7.39. *) Bugfix: improve handling of "select" method errors. *) Bugfix: of "select() failed (10022: ...)" error in nginx/Windows. *) Bugfix: in error text descriptions in nginx/Windows; the bug had appeared in 0.7.53.
author Igor Sysoev <http://sysoev.ru>
date Fri, 01 May 2009 00:00:00 +0400
parents 392c16f2d858
children 6484cbba0222
line wrap: on
line diff
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -1623,8 +1623,9 @@ ngx_http_upstream_process_headers(ngx_ht
 
     umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);
 
-    if (u->headers_in.x_accel_redirect) {
-
+    if (u->headers_in.x_accel_redirect
+        && !(u->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_XA_REDIRECT))
+    {
         ngx_http_upstream_finalize_request(r, u, NGX_DECLINED);
 
         part = &u->headers_in.headers.part;
@@ -2845,10 +2846,12 @@ static ngx_int_t
 ngx_http_upstream_process_cache_control(ngx_http_request_t *r,
     ngx_table_elt_t *h, ngx_uint_t offset)
 {
-    ngx_array_t       *pa;
-    ngx_table_elt_t  **ph;
-
-    pa = &r->upstream->headers_in.cache_control;
+    ngx_array_t          *pa;
+    ngx_table_elt_t     **ph;
+    ngx_http_upstream_t  *u;
+
+    u = r->upstream;
+    pa = &u->headers_in.cache_control;
 
     if (pa->elts == NULL) {
        if (ngx_array_init(pa, r->pool, 2, sizeof(ngx_table_elt_t *)) != NGX_OK)
@@ -2869,6 +2872,10 @@ ngx_http_upstream_process_cache_control(
     u_char     *p, *last;
     ngx_int_t   n;
 
+    if (u->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL) {
+        return NGX_OK;
+    }
+
     if (r->cache == NULL) {
         return NGX_OK;
     }
@@ -2882,7 +2889,7 @@ ngx_http_upstream_process_cache_control(
     if (ngx_strlcasestrn(h->value.data, last, (u_char *) "no-cache", 8 - 1)
         != NULL)
     {
-        r->upstream->cacheable = 0;
+        u->cacheable = 0;
         return NGX_OK;
     }
 
@@ -2904,12 +2911,12 @@ ngx_http_upstream_process_cache_control(
             continue;
         }
 
-        r->upstream->cacheable = 0;
+        u->cacheable = 0;
         return NGX_OK;
     }
 
     if (n == 0) {
-        r->upstream->cacheable = 0;
+        u->cacheable = 0;
         return NGX_OK;
     }
 
@@ -2925,12 +2932,19 @@ static ngx_int_t
 ngx_http_upstream_process_expires(ngx_http_request_t *r, ngx_table_elt_t *h,
     ngx_uint_t offset)
 {
-    r->upstream->headers_in.expires = h;
+    ngx_http_upstream_t  *u;
+
+    u = r->upstream;
+    u->headers_in.expires = h;
 
 #if (NGX_HTTP_CACHE)
     {
     time_t  expires;
 
+    if (u->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_EXPIRES) {
+        return NGX_OK;
+    }
+
     if (r->cache == NULL) {
         return NGX_OK;
     }
@@ -2942,7 +2956,7 @@ ngx_http_upstream_process_expires(ngx_ht
     expires = ngx_http_parse_time(h->value.data, h->value.len);
 
     if (expires == NGX_ERROR || expires < ngx_time()) {
-        r->upstream->cacheable = 0;
+        u->cacheable = 0;
         return NGX_OK;
     }
 
@@ -2958,7 +2972,10 @@ static ngx_int_t
 ngx_http_upstream_process_accel_expires(ngx_http_request_t *r,
     ngx_table_elt_t *h, ngx_uint_t offset)
 {
-    r->upstream->headers_in.x_accel_expires = h;
+    ngx_http_upstream_t  *u;
+
+    u = r->upstream;
+    u->headers_in.x_accel_expires = h;
 
 #if (NGX_HTTP_CACHE)
     {
@@ -2966,6 +2983,10 @@ ngx_http_upstream_process_accel_expires(
     size_t      len;
     ngx_int_t   n;
 
+    if (u->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_XA_EXPIRES) {
+        return NGX_OK;
+    }
+
     if (r->cache == NULL) {
         return NGX_OK;
     }
@@ -2978,7 +2999,7 @@ ngx_http_upstream_process_accel_expires(
 
         switch (n) {
         case 0:
-            r->upstream->cacheable = 0;
+            u->cacheable = 0;
         case NGX_ERROR:
             return NGX_OK;