Mercurial > hg > nginx
diff src/http/ngx_http_header_filter_module.c @ 2533:c843171d5dc2
axe r->port_text
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 24 Feb 2009 07:29:55 +0000 |
parents | aa53ef3e36e9 |
children | 0e6f00346fa1 |
line wrap: on
line diff
--- a/src/http/ngx_http_header_filter_module.c +++ b/src/http/ngx_http_header_filter_module.c @@ -315,26 +315,22 @@ ngx_http_header_filter(ngx_http_request_ break; } -#if (NGX_HTTP_SSL) - if (r->connection->ssl) { - len += sizeof("Location: https://") - 1 - + host.len - + r->headers_out.location->value.len + 2; + len += sizeof("Location: https://") - 1 + + host.len + + r->headers_out.location->value.len + 2; - if (clcf->port_in_redirect && port != 443) { - len += r->port_text->len; - } + if (clcf->port_in_redirect) { - } else +#if (NGX_HTTP_SSL) + if (r->connection->ssl) + port = (port == 443) ? 0 : port; + else #endif - { - len += sizeof("Location: http://") - 1 - + host.len - + r->headers_out.location->value.len + 2; + port = (port == 80) ? 0 : port; + } - if (clcf->port_in_redirect && port != 80) { - len += r->port_text->len; - } + if (port) { + len += sizeof(":65535") - 1; } } else { @@ -492,21 +488,8 @@ ngx_http_header_filter(ngx_http_request_ *b->last++ = ':'; *b->last++ = '/'; *b->last++ = '/'; b->last = ngx_copy(b->last, host.data, host.len); - if (clcf->port_in_redirect) { -#if (NGX_HTTP_SSL) - if (r->connection->ssl) { - if (port != 443) { - b->last = ngx_copy(b->last, r->port_text->data, - r->port_text->len); - } - } else -#endif - { - if (port != 80) { - b->last = ngx_copy(b->last, r->port_text->data, - r->port_text->len); - } - } + if (port) { + b->last = ngx_sprintf(b->last, ":%ui", port); } b->last = ngx_copy(b->last, r->headers_out.location->value.data,