comparison src/http/modules/ngx_http_proxy_module.c @ 6781:ca27074f8f0f

Proxy: support variables for proxy_method directive.
author Dmitry Lazurkin <dilaz03@gmail.com>
date Sun, 16 Oct 2016 18:24:01 +0300
parents 20eb4587225b
children 1af120241cde
comparison
equal deleted inserted replaced
6780:56d6bfe6b609 6781:ca27074f8f0f
71 71
72 ngx_array_t *redirects; 72 ngx_array_t *redirects;
73 ngx_array_t *cookie_domains; 73 ngx_array_t *cookie_domains;
74 ngx_array_t *cookie_paths; 74 ngx_array_t *cookie_paths;
75 75
76 ngx_str_t method; 76 ngx_http_complex_value_t *method;
77 ngx_str_t location; 77 ngx_str_t location;
78 ngx_str_t url; 78 ngx_str_t url;
79 79
80 #if (NGX_HTTP_CACHE) 80 #if (NGX_HTTP_CACHE)
81 ngx_http_complex_value_t cache_key; 81 ngx_http_complex_value_t cache_key;
378 offsetof(ngx_http_proxy_loc_conf_t, body_source), 378 offsetof(ngx_http_proxy_loc_conf_t, body_source),
379 NULL }, 379 NULL },
380 380
381 { ngx_string("proxy_method"), 381 { ngx_string("proxy_method"),
382 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, 382 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
383 ngx_conf_set_str_slot, 383 ngx_http_set_complex_value_slot,
384 NGX_HTTP_LOC_CONF_OFFSET, 384 NGX_HTTP_LOC_CONF_OFFSET,
385 offsetof(ngx_http_proxy_loc_conf_t, method), 385 offsetof(ngx_http_proxy_loc_conf_t, method),
386 NULL }, 386 NULL },
387 387
388 { ngx_string("proxy_pass_request_headers"), 388 { ngx_string("proxy_pass_request_headers"),
1157 1157
1158 if (u->method.len) { 1158 if (u->method.len) {
1159 /* HEAD was changed to GET to cache response */ 1159 /* HEAD was changed to GET to cache response */
1160 method = u->method; 1160 method = u->method;
1161 1161
1162 } else if (plcf->method.len) { 1162 } else if (plcf->method) {
1163 method = plcf->method; 1163 if (ngx_http_complex_value(r, plcf->method, &method) != NGX_OK) {
1164 return NGX_ERROR;
1165 }
1164 1166
1165 } else { 1167 } else {
1166 method = r->method_name; 1168 method = r->method_name;
1167 } 1169 }
1168 1170
2795 * conf->upstream.location = NULL; 2797 * conf->upstream.location = NULL;
2796 * conf->upstream.store_lengths = NULL; 2798 * conf->upstream.store_lengths = NULL;
2797 * conf->upstream.store_values = NULL; 2799 * conf->upstream.store_values = NULL;
2798 * conf->upstream.ssl_name = NULL; 2800 * conf->upstream.ssl_name = NULL;
2799 * 2801 *
2800 * conf->method = { 0, NULL }; 2802 * conf->method = NULL;
2801 * conf->headers_source = NULL; 2803 * conf->headers_source = NULL;
2802 * conf->headers.lengths = NULL; 2804 * conf->headers.lengths = NULL;
2803 * conf->headers.values = NULL; 2805 * conf->headers.values = NULL;
2804 * conf->headers.hash = { NULL, 0 }; 2806 * conf->headers.hash = { NULL, 0 };
2805 * conf->headers_cache.lengths = NULL; 2807 * conf->headers_cache.lengths = NULL;
3156 ngx_conf_merge_value(conf->upstream.cache_convert_head, 3158 ngx_conf_merge_value(conf->upstream.cache_convert_head,
3157 prev->upstream.cache_convert_head, 1); 3159 prev->upstream.cache_convert_head, 1);
3158 3160
3159 #endif 3161 #endif
3160 3162
3161 ngx_conf_merge_str_value(conf->method, prev->method, ""); 3163 if (conf->method == NULL) {
3164 conf->method = prev->method;
3165 }
3162 3166
3163 ngx_conf_merge_value(conf->upstream.pass_request_headers, 3167 ngx_conf_merge_value(conf->upstream.pass_request_headers,
3164 prev->upstream.pass_request_headers, 1); 3168 prev->upstream.pass_request_headers, 1);
3165 ngx_conf_merge_value(conf->upstream.pass_request_body, 3169 ngx_conf_merge_value(conf->upstream.pass_request_body,
3166 prev->upstream.pass_request_body, 1); 3170 prev->upstream.pass_request_body, 1);