diff src/http/modules/ngx_http_proxy_module.c @ 354:583decdb82a4 NGINX_0_6_21

nginx 0.6.21 *) Change: if variable values used in a "proxy_pass" directive contain IP-addresses only, then a "resolver" directive is not mandatory. resolver *) Bugfix: a segmentation fault might occur in worker process if a "proxy_pass" directive with URI-part was used; bug appeared in 0.6.19. *) Bugfix: if resolver was used on platform that does not support kqueue, then nginx issued an alert "name is out of response". Thanks to Andrei Nigmatulin. *) Bugfix: if the $server_protocol was used in FastCGI parameters and a request line length was near to the "client_header_buffer_size" directive value, then nginx issued an alert "fastcgi: the request record is too big". *) Bugfix: if a plain text HTTP/0.9 version request was made to HTTPS server, then nginx returned usual response.
author Igor Sysoev <http://sysoev.ru>
date Mon, 03 Dec 2007 00:00:00 +0300
parents 84b8345f70d5
children b743d290eb3b
line wrap: on
line diff
--- a/src/http/modules/ngx_http_proxy_module.c
+++ b/src/http/modules/ngx_http_proxy_module.c
@@ -675,7 +675,8 @@ ngx_http_proxy_create_request(ngx_http_r
                                         r->uri.len - loc_len, NGX_ESCAPE_URI);
         }
 
-        len += r->uri.len - loc_len + escape + sizeof("?") - 1 + r->args.len;
+        len += ctx->vars.uri.len + r->uri.len - loc_len + escape
+               + sizeof("?") - 1 + r->args.len;
     }
 
     ngx_http_script_flush_no_cacheable_variables(r, plcf->flushes);
@@ -2323,7 +2324,7 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_
         sc.variables = n;
         sc.complete_lengths = 1;
         sc.complete_values = 1;
-        
+
         if (ngx_http_script_compile(&sc) != NGX_OK) {
             return NGX_CONF_ERROR;
         }
@@ -2645,8 +2646,6 @@ static ngx_int_t
 ngx_http_proxy_set_vars(ngx_pool_t *pool, ngx_url_t *u,
     ngx_http_proxy_vars_t *v)
 {
-    u_char  *p;
-
     if (!u->unix_socket) {
         if (u->no_port || u->port == u->default_port) {
             v->host_header = u->host;
@@ -2661,16 +2660,9 @@ ngx_http_proxy_set_vars(ngx_pool_t *pool
             }
 
         } else {
-            p = ngx_palloc(pool, u->host.len + sizeof(":65536") - 1);
-            if (p == NULL) {
-                return NGX_ERROR;
-            }
-
-            v->host_header.len = ngx_sprintf(p, "%V:%d", &u->host, u->port) - p;
-            v->host_header.data = p;
-
-            v->port.len = v->host_header.len - u->host.len - 1;
-            v->port.data = p + u->host.len + 1;
+            v->host_header.len = u->host.len + 1 + u->port_text.len;
+            v->host_header.data = u->host.data;
+            v->port = u->port_text;
         }
 
     } else {