comparison src/http/modules/ngx_http_static_handler.c @ 290:87e73f067470

nginx-0.0.2-2004-03-16-10:10:12 import
author Igor Sysoev <igor@sysoev.ru>
date Tue, 16 Mar 2004 07:10:12 +0000
parents f81d075ad172
children 5cfd65b8b0a7
comparison
equal deleted inserted replaced
289:0750faf8d7e3 290:87e73f067470
58 }; 58 };
59 59
60 60
61 static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r) 61 static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r)
62 { 62 {
63 char *last; 63 u_char *last;
64 ngx_fd_t fd; 64 ngx_fd_t fd;
65 ngx_int_t rc; 65 ngx_int_t rc;
66 ngx_uint_t level; 66 ngx_uint_t level;
67 ngx_str_t name, location; 67 ngx_str_t name, location;
68 ngx_err_t err; 68 ngx_err_t err;
113 /* 113 /*
114 * make a file name, reserve 2 bytes for a trailing '/' 114 * make a file name, reserve 2 bytes for a trailing '/'
115 * in a possible redirect and for the last '\0' 115 * in a possible redirect and for the last '\0'
116 */ 116 */
117 117
118 name.data = ngx_palloc(r->pool, clcf->doc_root.len + r->uri.len + 2); 118 name.data = ngx_palloc(r->pool, clcf->root.len + r->uri.len + 2
119 - clcf->alias * clcf->name.len);
119 if (name.data == NULL) { 120 if (name.data == NULL) {
120 return NGX_HTTP_INTERNAL_SERVER_ERROR; 121 return NGX_HTTP_INTERNAL_SERVER_ERROR;
121 } 122 }
122 123
123 location.data = ngx_cpymem(name.data, clcf->doc_root.data, 124 location.data = ngx_cpymem(name.data, clcf->root.data, clcf->root.len);
124 clcf->doc_root.len); 125
125 last = ngx_cpystrn(location.data, r->uri.data, r->uri.len + 1); 126 if (clcf->alias) {
127 last = ngx_cpystrn(location.data, r->uri.data + clcf->name.len,
128 r->uri.len + 1 - clcf->name.len);
129
130 /*
131 * aliases usually have trailling "/",
132 * set it in the start of the possible redirect
133 */
134
135 if (*location.data != '/') {
136 location.data--;
137 }
138
139 } else {
140 last = ngx_cpystrn(location.data, r->uri.data, r->uri.len + 1);
141 }
142
126 name.len = last - name.data; 143 name.len = last - name.data;
127 location.len = last - location.data + 1; 144 location.len = last - location.data + 1;
128 145
129 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, 146 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0,
130 "http filename: \"%s\"", name.data); 147 "http filename: \"%s\"", name.data);