diff src/http/ngx_http_header_filter_module.c @ 66:818201e5a553 NGINX_0_1_33

nginx 0.1.33 *) Bugfix: nginx could not be built with the --without-pcre parameter; bug appeared in 0.1.29. *) Bugfix: 3, 4, 7, and 8 the "proxy_set_header" directives in one level cause the bus fault on start up. *) Bugfix: the HTTP protocol was specified in the HTTPS redirects. *) Bugfix: if the "rewrite" directive used the captures inside the "if" directive, then the 500 error code was returned.
author Igor Sysoev <http://sysoev.ru>
date Mon, 23 May 2005 00:00:00 +0400
parents df7d3fff122b
children 8ad297c88dcb
line wrap: on
line diff
--- a/src/http/ngx_http_header_filter_module.c
+++ b/src/http/ngx_http_header_filter_module.c
@@ -264,11 +264,26 @@ ngx_http_header_filter(ngx_http_request_
     {
         r->headers_out.location->hash = 0;
 
-        len += sizeof("Location: http://") - 1
-               + r->server_name.len + r->headers_out.location->value.len + 2;
+#if (NGX_HTTP_SSL)
+        if (r->connection->ssl) {
+            len += sizeof("Location: https://") - 1
+                   + r->server_name.len
+                   + r->headers_out.location->value.len + 2;
+
+            if (r->port != 443) {
+                len += r->port_text->len;
+            }
 
-        if (r->port != 80) {
-            len += r->port_text->len;
+        } else
+#endif
+        {
+            len += sizeof("Location: http://") - 1
+                   + r->server_name.len
+                   + r->headers_out.location->value.len + 2;
+
+            if (r->port != 80) {
+                len += r->port_text->len;
+            }
         }
     }
 
@@ -396,13 +411,33 @@ ngx_http_header_filter(ngx_http_request_
         && r->headers_out.location->value.data[0] == '/')
     {
         p = b->last + sizeof("Location: ") - 1;
-        b->last = ngx_cpymem(b->last, "Location: http://",
-                             sizeof("Location: http://") - 1);
+
+        b->last = ngx_cpymem(b->last, "Location: http",
+                             sizeof("Location: http") - 1);
+
+#if (NGX_HTTP_SSL)
+        if (r->connection->ssl) {
+            *b->last++ ='s';
+        }
+#endif
+
+        *b->last++ = ':'; *b->last++ = '/'; *b->last++ = '/';
         b->last = ngx_cpymem(b->last, r->server_name.data,
                              r->server_name.len);
-        if (r->port != 80) {
-            b->last = ngx_cpymem(b->last, r->port_text->data,
-                                 r->port_text->len);
+
+#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
+#endif
+        {
+            if (r->port != 80) {
+                b->last = ngx_cpymem(b->last, r->port_text->data,
+                                     r->port_text->len);
+            }
         }
 
         b->last = ngx_cpymem(b->last, r->headers_out.location->value.data,