diff src/http/modules/ngx_http_proxy_module.c @ 238:a528ae0fe909 NGINX_0_4_4

nginx 0.4.4 *) Feature: the $scheme variable. *) Feature: the "expires" directive supports the "max" parameter. *) Feature: the "include" directive supports the "*" mask. Thanks to Jonathan Dance. *) Bugfix: the "return" directive always overrode the "error_page" response code redirected by the "error_page" directive. *) Bugfix: a segmentation fault occurred if zero-length body was in PUT method. *) Bugfix: the redirect was changed incorrectly if the variables were used in the "proxy_redirect" directive.
author Igor Sysoev <http://sysoev.ru>
date Mon, 02 Oct 2006 00:00:00 +0400
parents dd6c66b5b0e2
children 500a3242dff6
line wrap: on
line diff
--- 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
     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
         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;