Mercurial > hg > nginx-vendor-1-0
comparison 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 |
comparison
equal
deleted
inserted
replaced
483:0a2f4b42ddad | 484:ed5e10fb40fc |
---|---|
1621 ngx_http_upstream_header_t *hh; | 1621 ngx_http_upstream_header_t *hh; |
1622 ngx_http_upstream_main_conf_t *umcf; | 1622 ngx_http_upstream_main_conf_t *umcf; |
1623 | 1623 |
1624 umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module); | 1624 umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module); |
1625 | 1625 |
1626 if (u->headers_in.x_accel_redirect) { | 1626 if (u->headers_in.x_accel_redirect |
1627 | 1627 && !(u->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_XA_REDIRECT)) |
1628 { | |
1628 ngx_http_upstream_finalize_request(r, u, NGX_DECLINED); | 1629 ngx_http_upstream_finalize_request(r, u, NGX_DECLINED); |
1629 | 1630 |
1630 part = &u->headers_in.headers.part; | 1631 part = &u->headers_in.headers.part; |
1631 h = part->elts; | 1632 h = part->elts; |
1632 | 1633 |
2843 | 2844 |
2844 static ngx_int_t | 2845 static ngx_int_t |
2845 ngx_http_upstream_process_cache_control(ngx_http_request_t *r, | 2846 ngx_http_upstream_process_cache_control(ngx_http_request_t *r, |
2846 ngx_table_elt_t *h, ngx_uint_t offset) | 2847 ngx_table_elt_t *h, ngx_uint_t offset) |
2847 { | 2848 { |
2848 ngx_array_t *pa; | 2849 ngx_array_t *pa; |
2849 ngx_table_elt_t **ph; | 2850 ngx_table_elt_t **ph; |
2850 | 2851 ngx_http_upstream_t *u; |
2851 pa = &r->upstream->headers_in.cache_control; | 2852 |
2853 u = r->upstream; | |
2854 pa = &u->headers_in.cache_control; | |
2852 | 2855 |
2853 if (pa->elts == NULL) { | 2856 if (pa->elts == NULL) { |
2854 if (ngx_array_init(pa, r->pool, 2, sizeof(ngx_table_elt_t *)) != NGX_OK) | 2857 if (ngx_array_init(pa, r->pool, 2, sizeof(ngx_table_elt_t *)) != NGX_OK) |
2855 { | 2858 { |
2856 return NGX_ERROR; | 2859 return NGX_ERROR; |
2867 #if (NGX_HTTP_CACHE) | 2870 #if (NGX_HTTP_CACHE) |
2868 { | 2871 { |
2869 u_char *p, *last; | 2872 u_char *p, *last; |
2870 ngx_int_t n; | 2873 ngx_int_t n; |
2871 | 2874 |
2875 if (u->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL) { | |
2876 return NGX_OK; | |
2877 } | |
2878 | |
2872 if (r->cache == NULL) { | 2879 if (r->cache == NULL) { |
2873 return NGX_OK; | 2880 return NGX_OK; |
2874 } | 2881 } |
2875 | 2882 |
2876 if (r->cache->valid_sec != 0) { | 2883 if (r->cache->valid_sec != 0) { |
2880 last = h->value.data + h->value.len; | 2887 last = h->value.data + h->value.len; |
2881 | 2888 |
2882 if (ngx_strlcasestrn(h->value.data, last, (u_char *) "no-cache", 8 - 1) | 2889 if (ngx_strlcasestrn(h->value.data, last, (u_char *) "no-cache", 8 - 1) |
2883 != NULL) | 2890 != NULL) |
2884 { | 2891 { |
2885 r->upstream->cacheable = 0; | 2892 u->cacheable = 0; |
2886 return NGX_OK; | 2893 return NGX_OK; |
2887 } | 2894 } |
2888 | 2895 |
2889 p = ngx_strlcasestrn(h->value.data, last, (u_char *) "max-age=", 8 - 1); | 2896 p = ngx_strlcasestrn(h->value.data, last, (u_char *) "max-age=", 8 - 1); |
2890 | 2897 |
2902 if (*p >= '0' && *p <= '9') { | 2909 if (*p >= '0' && *p <= '9') { |
2903 n = n * 10 + *p - '0'; | 2910 n = n * 10 + *p - '0'; |
2904 continue; | 2911 continue; |
2905 } | 2912 } |
2906 | 2913 |
2907 r->upstream->cacheable = 0; | 2914 u->cacheable = 0; |
2908 return NGX_OK; | 2915 return NGX_OK; |
2909 } | 2916 } |
2910 | 2917 |
2911 if (n == 0) { | 2918 if (n == 0) { |
2912 r->upstream->cacheable = 0; | 2919 u->cacheable = 0; |
2913 return NGX_OK; | 2920 return NGX_OK; |
2914 } | 2921 } |
2915 | 2922 |
2916 r->cache->valid_sec = ngx_time() + n; | 2923 r->cache->valid_sec = ngx_time() + n; |
2917 } | 2924 } |
2923 | 2930 |
2924 static ngx_int_t | 2931 static ngx_int_t |
2925 ngx_http_upstream_process_expires(ngx_http_request_t *r, ngx_table_elt_t *h, | 2932 ngx_http_upstream_process_expires(ngx_http_request_t *r, ngx_table_elt_t *h, |
2926 ngx_uint_t offset) | 2933 ngx_uint_t offset) |
2927 { | 2934 { |
2928 r->upstream->headers_in.expires = h; | 2935 ngx_http_upstream_t *u; |
2936 | |
2937 u = r->upstream; | |
2938 u->headers_in.expires = h; | |
2929 | 2939 |
2930 #if (NGX_HTTP_CACHE) | 2940 #if (NGX_HTTP_CACHE) |
2931 { | 2941 { |
2932 time_t expires; | 2942 time_t expires; |
2933 | 2943 |
2944 if (u->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_EXPIRES) { | |
2945 return NGX_OK; | |
2946 } | |
2947 | |
2934 if (r->cache == NULL) { | 2948 if (r->cache == NULL) { |
2935 return NGX_OK; | 2949 return NGX_OK; |
2936 } | 2950 } |
2937 | 2951 |
2938 if (r->cache->valid_sec != 0) { | 2952 if (r->cache->valid_sec != 0) { |
2940 } | 2954 } |
2941 | 2955 |
2942 expires = ngx_http_parse_time(h->value.data, h->value.len); | 2956 expires = ngx_http_parse_time(h->value.data, h->value.len); |
2943 | 2957 |
2944 if (expires == NGX_ERROR || expires < ngx_time()) { | 2958 if (expires == NGX_ERROR || expires < ngx_time()) { |
2945 r->upstream->cacheable = 0; | 2959 u->cacheable = 0; |
2946 return NGX_OK; | 2960 return NGX_OK; |
2947 } | 2961 } |
2948 | 2962 |
2949 r->cache->valid_sec = expires; | 2963 r->cache->valid_sec = expires; |
2950 } | 2964 } |
2956 | 2970 |
2957 static ngx_int_t | 2971 static ngx_int_t |
2958 ngx_http_upstream_process_accel_expires(ngx_http_request_t *r, | 2972 ngx_http_upstream_process_accel_expires(ngx_http_request_t *r, |
2959 ngx_table_elt_t *h, ngx_uint_t offset) | 2973 ngx_table_elt_t *h, ngx_uint_t offset) |
2960 { | 2974 { |
2961 r->upstream->headers_in.x_accel_expires = h; | 2975 ngx_http_upstream_t *u; |
2976 | |
2977 u = r->upstream; | |
2978 u->headers_in.x_accel_expires = h; | |
2962 | 2979 |
2963 #if (NGX_HTTP_CACHE) | 2980 #if (NGX_HTTP_CACHE) |
2964 { | 2981 { |
2965 u_char *p; | 2982 u_char *p; |
2966 size_t len; | 2983 size_t len; |
2967 ngx_int_t n; | 2984 ngx_int_t n; |
2968 | 2985 |
2986 if (u->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_XA_EXPIRES) { | |
2987 return NGX_OK; | |
2988 } | |
2989 | |
2969 if (r->cache == NULL) { | 2990 if (r->cache == NULL) { |
2970 return NGX_OK; | 2991 return NGX_OK; |
2971 } | 2992 } |
2972 | 2993 |
2973 len = h->value.len; | 2994 len = h->value.len; |
2976 if (p[0] != '@') { | 2997 if (p[0] != '@') { |
2977 n = ngx_atoi(p, len); | 2998 n = ngx_atoi(p, len); |
2978 | 2999 |
2979 switch (n) { | 3000 switch (n) { |
2980 case 0: | 3001 case 0: |
2981 r->upstream->cacheable = 0; | 3002 u->cacheable = 0; |
2982 case NGX_ERROR: | 3003 case NGX_ERROR: |
2983 return NGX_OK; | 3004 return NGX_OK; |
2984 | 3005 |
2985 default: | 3006 default: |
2986 r->cache->valid_sec = ngx_time() + n; | 3007 r->cache->valid_sec = ngx_time() + n; |