diff src/http/ngx_http_header_filter_module.c @ 70:8ad297c88dcb NGINX_0_1_35

nginx 0.1.35 *) Feature: the "working_directory" directive. *) Feature: the "port_in_redirect" directive. *) Bugfix: the segmentation fault was occurred if the backend response header was in several packets; bug appeared in 0.1.29. *) Bugfix: if more than 10 servers were configured or some server did not use the "listen" directive, then the segmentation fault was occurred on the start. *) Bugfix: the segmentation fault might occur if the response was bigger than the temporary file. *) Bugfix: nginx returned the 400 response on requests like "GET http://www.domain.com/uri HTTP/1.0"; bug appeared in 0.1.28.
author Igor Sysoev <http://sysoev.ru>
date Tue, 07 Jun 2005 00:00:00 +0400
parents 818201e5a553
children 71c46860eb55
line wrap: on
line diff
--- a/src/http/ngx_http_header_filter_module.c
+++ b/src/http/ngx_http_header_filter_module.c
@@ -258,6 +258,8 @@ ngx_http_header_filter(ngx_http_request_
         len += sizeof("Last-Modified: Mon, 28 Sep 1970 06:00:00 GMT" CRLF) - 1;
     }
 
+    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+
     if (r->headers_out.location
         && r->headers_out.location->value.len
         && r->headers_out.location->value.data[0] == '/')
@@ -270,7 +272,7 @@ ngx_http_header_filter(ngx_http_request_
                    + r->server_name.len
                    + r->headers_out.location->value.len + 2;
 
-            if (r->port != 443) {
+            if (clcf->port_in_redirect && r->port != 443) {
                 len += r->port_text->len;
             }
 
@@ -281,7 +283,7 @@ ngx_http_header_filter(ngx_http_request_
                    + r->server_name.len
                    + r->headers_out.location->value.len + 2;
 
-            if (r->port != 80) {
+            if (clcf->port_in_redirect && r->port != 80) {
                 len += r->port_text->len;
             }
         }
@@ -291,8 +293,6 @@ ngx_http_header_filter(ngx_http_request_
         len += sizeof("Transfer-Encoding: chunked" CRLF) - 1;
     }
 
-    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
-
     if (r->keepalive) {
         len += sizeof("Connection: keep-alive" CRLF) - 1;
 
@@ -425,18 +425,20 @@ ngx_http_header_filter(ngx_http_request_
         b->last = ngx_cpymem(b->last, r->server_name.data,
                              r->server_name.len);
 
+        if (clcf->port_in_redirect) {
 #if (NGX_HTTP_SSL)
-        if (r->connection->ssl) {
-            if (r->port != 443) {
-                b->last = ngx_cpymem(b->last, r->port_text->data,
-                                     r->port_text->len);
-            }
-        } else
+            if (r->connection->ssl) {
+                if (r->port != 443) {
+                    b->last = ngx_cpymem(b->last, r->port_text->data,
+                                         r->port_text->len);
+                }
+            } else
 #endif
-        {
-            if (r->port != 80) {
-                b->last = ngx_cpymem(b->last, r->port_text->data,
-                                     r->port_text->len);
+            {
+                if (r->port != 80) {
+                    b->last = ngx_cpymem(b->last, r->port_text->data,
+                                         r->port_text->len);
+                }
             }
         }