From c9098081e2086757d089658bab60f5903af91d33 Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Tue, 26 Sep 2006 21:15:52 +0000 Subject: [PATCH] fix proxy_redirect with variable --- src/http/modules/ngx_http_proxy_module.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c index 0d80b3143..f4007be8e 100644 --- a/src/http/modules/ngx_http_proxy_module.c +++ b/src/http/modules/ngx_http_proxy_module.c @@ -1397,8 +1397,11 @@ ngx_http_proxy_rewrite_redirect_vars(ngx_http_request_t *r, ngx_table_elt_t *h, e.ip = pr->replacement.vars.lengths; e.request = r; - for (len = prefix; *(uintptr_t *) e.ip; len += lcode(&e)) { + len = prefix + h->value.len - pr->redirect.len; + + while (*(uintptr_t *) e.ip) { lcode = *(ngx_http_script_len_code_pt *) e.ip; + len += lcode(&e); } data = ngx_palloc(r->pool, len); @@ -1418,6 +1421,9 @@ ngx_http_proxy_rewrite_redirect_vars(ngx_http_request_t *r, ngx_table_elt_t *h, code(&e); } + ngx_memcpy(e.pos, h->value.data + prefix + pr->redirect.len, + h->value.len - pr->redirect.len - prefix); + h->value.len = len; h->value.data = data;