comparison src/http/modules/ngx_http_static_module.c @ 380:bc21d9cd9c54 NGINX_0_7_2

nginx 0.7.2 *) Feature: now nginx supports EDH key exchange ciphers. *) Feature: the "ssl_dhparam" directive. *) Feature: the $ssl_client_cert variable. Thanks to Manlio Perillo. *) Bugfix: after changing URI via a "rewrite" directive nginx did not search a new location; bug appeared in 0.7.1. Thanks to Maxim Dounin. *) Bugfix: nginx could not be built without PCRE library; bug appeared in 0.7.1. *) 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 Mon, 16 Jun 2008 00:00:00 +0400
parents 54fad6c4b555
children 984bb0b1399b
comparison
equal deleted inserted replaced
379:9d9dad60269f 380:bc21d9cd9c54
46 46
47 static ngx_int_t 47 static ngx_int_t
48 ngx_http_static_handler(ngx_http_request_t *r) 48 ngx_http_static_handler(ngx_http_request_t *r)
49 { 49 {
50 u_char *last, *location; 50 u_char *last, *location;
51 size_t root; 51 size_t root, len;
52 ngx_str_t path; 52 ngx_str_t path;
53 ngx_int_t rc; 53 ngx_int_t rc;
54 ngx_uint_t level; 54 ngx_uint_t level;
55 ngx_log_t *log; 55 ngx_log_t *log;
56 ngx_buf_t *b; 56 ngx_buf_t *b;
148 r->headers_out.location = ngx_palloc(r->pool, sizeof(ngx_table_elt_t)); 148 r->headers_out.location = ngx_palloc(r->pool, sizeof(ngx_table_elt_t));
149 if (r->headers_out.location == NULL) { 149 if (r->headers_out.location == NULL) {
150 return NGX_HTTP_INTERNAL_SERVER_ERROR; 150 return NGX_HTTP_INTERNAL_SERVER_ERROR;
151 } 151 }
152 152
153 if (!clcf->alias && clcf->root_lengths == NULL) { 153 len = r->uri.len + 1;
154
155 if (!clcf->alias && clcf->root_lengths == NULL && r->args.len == 0) {
154 location = path.data + clcf->root.len; 156 location = path.data + clcf->root.len;
155 157
158 *last = '/';
159
156 } else { 160 } else {
157 location = ngx_palloc(r->pool, r->uri.len + 1); 161 if (r->args.len) {
162 len += r->args.len + 1;
163 }
164
165 location = ngx_palloc(r->pool, len);
158 if (location == NULL) { 166 if (location == NULL) {
159 return NGX_HTTP_INTERNAL_SERVER_ERROR; 167 return NGX_HTTP_INTERNAL_SERVER_ERROR;
160 } 168 }
161 169
162 last = ngx_copy(location, r->uri.data, r->uri.len); 170 last = ngx_copy(location, r->uri.data, r->uri.len);
163 } 171
164 172 *last = '/';
165 *last = '/'; 173
174 if (r->args.len) {
175 *++last = '?';
176 ngx_memcpy(++last, r->args.data, r->args.len);
177 }
178 }
166 179
167 /* 180 /*
168 * we do not need to set the r->headers_out.location->hash and 181 * we do not need to set the r->headers_out.location->hash and
169 * r->headers_out.location->key fields 182 * r->headers_out.location->key fields
170 */ 183 */
171 184
172 r->headers_out.location->value.len = r->uri.len + 1; 185 r->headers_out.location->value.len = len;
173 r->headers_out.location->value.data = location; 186 r->headers_out.location->value.data = location;
174 187
175 return NGX_HTTP_MOVED_PERMANENTLY; 188 return NGX_HTTP_MOVED_PERMANENTLY;
176 } 189 }
177 190