comparison src/http/modules/ngx_http_static_handler.c @ 400:69e851f83522

nginx-0.0.8-2004-07-26-20:21:18 import
author Igor Sysoev <igor@sysoev.ru>
date Mon, 26 Jul 2004 16:21:18 +0000
parents 6f3b20c1ac50
children ea3113b181d1
comparison
equal deleted inserted replaced
399:4e21d1291a14 400:69e851f83522
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->root.len + r->uri.len + 2
119 - clcf->alias * clcf->name.len);
120 if (name.data == NULL) {
121 return NGX_HTTP_INTERNAL_SERVER_ERROR;
122 }
123
124 location.data = ngx_cpymem(name.data, clcf->root.data, clcf->root.len);
125
126 if (clcf->alias) { 118 if (clcf->alias) {
127 last = ngx_cpystrn(location.data, r->uri.data + clcf->name.len, 119 name.data = ngx_palloc(r->pool, clcf->root.len + r->uri.len + 2
120 - clcf->name.len);
121 if (name.data == NULL) {
122 return NGX_HTTP_INTERNAL_SERVER_ERROR;
123 }
124
125 last = ngx_cpymem(name.data, clcf->root.data, clcf->root.len);
126 last = ngx_cpystrn(last, r->uri.data + clcf->name.len,
128 r->uri.len + 1 - clcf->name.len); 127 r->uri.len + 1 - clcf->name.len);
129 128
129 name.len = last - name.data;
130
131 location.data = ngx_palloc(r->pool, r->uri.len + 2);
132 if (location.data == NULL) {
133 return NGX_HTTP_INTERNAL_SERVER_ERROR;
134 }
135
136 last = ngx_cpystrn(location.data, r->uri.data, r->uri.len + 1);
137
138 #if 0
130 /* 139 /*
131 * aliases usually have trailling "/", 140 * aliases usually have trailling "/",
132 * set it in the start of the possible redirect 141 * set it in the start of the possible redirect
133 */ 142 */
134 143
135 if (*location.data != '/') { 144 if (*location.data != '/') {
136 location.data--; 145 location.data--;
137 } 146 }
147 #endif
148
149 location.len = last - location.data + 1;
138 150
139 } else { 151 } else {
152 name.data = ngx_palloc(r->pool, clcf->root.len + r->uri.len + 2);
153 if (name.data == NULL) {
154 return NGX_HTTP_INTERNAL_SERVER_ERROR;
155 }
156
157 location.data = ngx_cpymem(name.data, clcf->root.data, clcf->root.len);
140 last = ngx_cpystrn(location.data, r->uri.data, r->uri.len + 1); 158 last = ngx_cpystrn(location.data, r->uri.data, r->uri.len + 1);
141 } 159
142 160 name.len = last - name.data;
143 name.len = last - name.data; 161 location.len = last - location.data + 1;
144 location.len = last - location.data + 1; 162 }
145 163
146 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, 164 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0,
147 "http filename: \"%s\"", name.data); 165 "http filename: \"%s\"", name.data);
148 166
149 167