Mercurial > hg > nginx-vendor-0-6
diff src/http/modules/ngx_http_static_module.c @ 380:3ce4580ae286 NGINX_0_6_34
nginx 0.6.34
*) Change: now the EAGAIN error returned by connect() is not considered
as temporary error.
*) Change: now the "gzip_vary" directive turned on issues a
"Vary: Accept-Encoding" header line for uncompressed responses too.
*) Feature: the "expires" directive supports daily time.
*) Feature: the "Expect" request header line support.
*) Feature: now the "rewrite" directive does a redirect automatically
if the "https://" protocol is used.
*) Bugfix: the "listen" directive parameters such as "backlog",
"rcvbuf", etc. were not set, if a default server was not the first
one.
*) Bugfix: the "log_not_found" directive did not work for index files
tests.
*) Bugfix: now if FastCGI server sends a "Location" header line without
status line, then nginx uses 302 status code.
Thanks to Maxim Dounin.
*) Bugfix: the ngx_http_flv_module did not support several values in a
query string.
*) Bugfix: when a request to a directory was redirected with the slash
added, nginx dropped a query string from the original request.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Thu, 27 Nov 2008 00:00:00 +0300 |
parents | fc497c1dfb7c |
children |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_static_module.c +++ b/src/http/modules/ngx_http_static_module.c @@ -48,7 +48,7 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r) { u_char *last, *location; - size_t root; + size_t root, len; ngx_str_t path; ngx_int_t rc; ngx_uint_t level; @@ -144,26 +144,39 @@ ngx_http_static_handler(ngx_http_request return NGX_HTTP_INTERNAL_SERVER_ERROR; } - if (!clcf->alias && clcf->root_lengths == NULL) { + len = r->uri.len + 1; + + if (!clcf->alias && clcf->root_lengths == NULL && r->args.len == 0) { location = path.data + clcf->root.len; + *last = '/'; + } else { - location = ngx_palloc(r->pool, r->uri.len + 1); + if (r->args.len) { + len += r->args.len + 1; + } + + location = ngx_palloc(r->pool, len); if (location == NULL) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } last = ngx_copy(location, r->uri.data, r->uri.len); - } + + *last = '/'; - *last = '/'; + if (r->args.len) { + *++last = '?'; + ngx_memcpy(++last, r->args.data, r->args.len); + } + } /* * we do not need to set the r->headers_out.location->hash and * r->headers_out.location->key fields */ - r->headers_out.location->value.len = r->uri.len + 1; + r->headers_out.location->value.len = len; r->headers_out.location->value.data = location; return NGX_HTTP_MOVED_PERMANENTLY;