comparison src/http/modules/ngx_http_proxy_module.c @ 4275:bb909c0c8629

Fixed proxy_set_header inheritance with proxy_set_body.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 14 Nov 2011 13:19:56 +0000
parents 595560d9dcbf
children a0f18c78db3b
comparison
equal deleted inserted replaced
4274:595560d9dcbf 4275:bb909c0c8629
2491 ngx_http_proxy_loc_conf_t *prev = parent; 2491 ngx_http_proxy_loc_conf_t *prev = parent;
2492 ngx_http_proxy_loc_conf_t *conf = child; 2492 ngx_http_proxy_loc_conf_t *conf = child;
2493 2493
2494 u_char *p; 2494 u_char *p;
2495 size_t size; 2495 size_t size;
2496 ngx_keyval_t *s;
2497 ngx_hash_init_t hash; 2496 ngx_hash_init_t hash;
2498 ngx_http_core_loc_conf_t *clcf; 2497 ngx_http_core_loc_conf_t *clcf;
2499 ngx_http_proxy_redirect_t *pr; 2498 ngx_http_proxy_redirect_t *pr;
2500 ngx_http_script_compile_t sc; 2499 ngx_http_script_compile_t sc;
2501 2500
2839 sc.complete_values = 1; 2838 sc.complete_values = 1;
2840 2839
2841 if (ngx_http_script_compile(&sc) != NGX_OK) { 2840 if (ngx_http_script_compile(&sc) != NGX_OK) {
2842 return NGX_CONF_ERROR; 2841 return NGX_CONF_ERROR;
2843 } 2842 }
2844
2845 if (conf->headers_source == NULL) {
2846 conf->headers_source = ngx_array_create(cf->pool, 4,
2847 sizeof(ngx_keyval_t));
2848 if (conf->headers_source == NULL) {
2849 return NGX_CONF_ERROR;
2850 }
2851 }
2852
2853 s = ngx_array_push(conf->headers_source);
2854 if (s == NULL) {
2855 return NGX_CONF_ERROR;
2856 }
2857
2858 ngx_str_set(&s->key, "Content-Length");
2859 ngx_str_set(&s->value, "$proxy_internal_body_length");
2860 } 2843 }
2861 2844
2862 if (ngx_http_proxy_merge_headers(cf, conf, prev) != NGX_OK) { 2845 if (ngx_http_proxy_merge_headers(cf, conf, prev) != NGX_OK) {
2863 return NGX_CONF_ERROR; 2846 return NGX_CONF_ERROR;
2864 } 2847 }
2889 conf->headers_set_hash = prev->headers_set_hash; 2872 conf->headers_set_hash = prev->headers_set_hash;
2890 conf->headers_source = prev->headers_source; 2873 conf->headers_source = prev->headers_source;
2891 } 2874 }
2892 2875
2893 if (conf->headers_set_hash.buckets 2876 if (conf->headers_set_hash.buckets
2877 && ((conf->body_source.data == NULL)
2878 == (prev->body_source.data == NULL))
2894 #if (NGX_HTTP_CACHE) 2879 #if (NGX_HTTP_CACHE)
2895 && ((conf->upstream.cache == NULL) == (prev->upstream.cache == NULL)) 2880 && ((conf->upstream.cache == NULL) == (prev->upstream.cache == NULL))
2896 #endif 2881 #endif
2897 ) 2882 )
2898 { 2883 {
2969 *s = *h; 2954 *s = *h;
2970 2955
2971 next: 2956 next:
2972 2957
2973 h++; 2958 h++;
2959 }
2960
2961 if (conf->body_source.data) {
2962 s = ngx_array_push(&headers_merged);
2963 if (s == NULL) {
2964 return NGX_ERROR;
2965 }
2966
2967 ngx_str_set(&s->key, "Content-Length");
2968 ngx_str_set(&s->value, "$proxy_internal_body_length");
2974 } 2969 }
2975 2970
2976 2971
2977 src = headers_merged.elts; 2972 src = headers_merged.elts;
2978 for (i = 0; i < headers_merged.nelts; i++) { 2973 for (i = 0; i < headers_merged.nelts; i++) {