Mercurial > hg > nginx-vendor-current
diff src/http/ngx_http_header_filter_module.c @ 362:54fad6c4b555 NGINX_0_6_25
nginx 0.6.25
*) Change: now the "server_name_in_redirect" directive is used instead
of the "server_name" directive's special "*" parameter.
*) Change: now wildcard and regex names can be used as main name in a
"server_name" directive.
*) Change: the "satisfy_any" directive was replaced by the "satisfy"
directive.
*) Workaround: old worker processes might hog CPU after reconfiguration
if they was run under Linux OpenVZ.
*) Feature: the "min_delete_depth" directive.
*) Bugfix: the COPY and MOVE methods did not work with single files.
*) Bugfix: the ngx_http_gzip_static_module did not allow the
ngx_http_dav_module to work; bug appeared in 0.6.23.
*) Bugfix: socket leak in HTTPS mode if deferred accept was used.
Thanks to Ben Maurer.
*) Bugfix: nginx could not be built without PCRE library; bug appeared
in 0.6.23.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Tue, 08 Jan 2008 00:00:00 +0300 |
parents | 9121a0a91f47 |
children | edf1cb6c328e |
line wrap: on
line diff
--- a/src/http/ngx_http_header_filter_module.c +++ b/src/http/ngx_http_header_filter_module.c @@ -153,12 +153,16 @@ ngx_http_header_filter(ngx_http_request_ { u_char *p; size_t len; + ngx_str_t host; ngx_buf_t *b; ngx_uint_t status, i; ngx_chain_t out; ngx_list_part_t *part; ngx_table_elt_t *header; ngx_http_core_loc_conf_t *clcf; + ngx_http_core_srv_conf_t *cscf; + /* AF_INET only */ + u_char addr[INET_ADDRSTRLEN]; r->header_sent = 1; @@ -278,10 +282,26 @@ ngx_http_header_filter(ngx_http_request_ { r->headers_out.location->hash = 0; + if (clcf->server_name_in_redirect) { + cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); + host = cscf->server_name; + + } else if (r->headers_in.host) { + host.len = r->headers_in.host_name_len; + host.data = r->headers_in.host->value.data; + + } else { + host.data = addr; + + if (ngx_http_server_addr(r, &host) != NGX_OK) { + return NGX_ERROR; + } + } + #if (NGX_HTTP_SSL) if (r->connection->ssl) { len += sizeof("Location: https://") - 1 - + r->server_name.len + + host.len + r->headers_out.location->value.len + 2; if (clcf->port_in_redirect && r->port != 443) { @@ -292,13 +312,17 @@ ngx_http_header_filter(ngx_http_request_ #endif { len += sizeof("Location: http://") - 1 - + r->server_name.len + + host.len + r->headers_out.location->value.len + 2; if (clcf->port_in_redirect && r->port != 80) { len += r->port_text->len; } } + + } else { + host.len = 0; + host.data = NULL; } if (r->chunked) { @@ -428,10 +452,8 @@ ngx_http_header_filter(ngx_http_request_ *b->last++ = CR; *b->last++ = LF; } - if (r->headers_out.location - && r->headers_out.location->value.len - && r->headers_out.location->value.data[0] == '/') - { + if (host.data) { + p = b->last + sizeof("Location: ") - 1; b->last = ngx_cpymem(b->last, "Location: http", @@ -444,7 +466,7 @@ ngx_http_header_filter(ngx_http_request_ #endif *b->last++ = ':'; *b->last++ = '/'; *b->last++ = '/'; - b->last = ngx_copy(b->last, r->server_name.data, r->server_name.len); + b->last = ngx_copy(b->last, host.data, host.len); if (clcf->port_in_redirect) { #if (NGX_HTTP_SSL)