comparison src/http/modules/ngx_http_static_handler.c @ 165:894a01c6aea3

nginx-0.0.1-2003-10-29-20:39:05 import
author Igor Sysoev <igor@sysoev.ru>
date Wed, 29 Oct 2003 17:39:05 +0000
parents e7e094d34162
children c42be4185301
comparison
equal deleted inserted replaced
164:84036764e215 165:894a01c6aea3
39 39
40 int ngx_http_static_translate_handler(ngx_http_request_t *r) 40 int ngx_http_static_translate_handler(ngx_http_request_t *r)
41 { 41 {
42 char *location, *last; 42 char *location, *last;
43 ngx_err_t err; 43 ngx_err_t err;
44 ngx_table_elt_t *h;
45 ngx_http_core_loc_conf_t *clcf; 44 ngx_http_core_loc_conf_t *clcf;
46 45
47 if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) { 46 if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) {
48 return NGX_HTTP_NOT_ALLOWED; 47 return NGX_HTTP_NOT_ALLOWED;
49 } 48 }
179 178
180 r->file.fd = NGX_INVALID_FILE; 179 r->file.fd = NGX_INVALID_FILE;
181 r->file.info_valid = 0; 180 r->file.info_valid = 0;
182 #endif 181 #endif
183 182
184 ngx_test_null(h, ngx_push_table(r->headers_out.headers), 183 if (!(r->headers_out.location =
185 NGX_HTTP_INTERNAL_SERVER_ERROR); 184 ngx_http_add_header(&r->headers_out, ngx_http_headers_out)))
185 {
186 return NGX_HTTP_INTERNAL_SERVER_ERROR;
187 }
186 188
187 *last++ = '/'; 189 *last++ = '/';
188 *last = '\0'; 190 *last = '\0';
189 h->key.len = 8; 191 r->headers_out.location->key.len = 8;
190 h->key.data = "Location" ; 192 r->headers_out.location->key.data = "Location" ;
191 h->value.len = last - location; 193 r->headers_out.location->value.len = last - location;
192 h->value.data = location; 194 r->headers_out.location->value.data = location;
193 r->headers_out.location = h;
194 195
195 return NGX_HTTP_MOVED_PERMANENTLY; 196 return NGX_HTTP_MOVED_PERMANENTLY;
196 } 197 }
197 198
198 r->content_handler = ngx_http_static_handler; 199 r->content_handler = ngx_http_static_handler;
260 261
261 r->headers_out.status = NGX_HTTP_OK; 262 r->headers_out.status = NGX_HTTP_OK;
262 r->headers_out.content_length_n = ngx_file_size(r->file.info); 263 r->headers_out.content_length_n = ngx_file_size(r->file.info);
263 r->headers_out.last_modified_time = ngx_file_mtime(r->file.info); 264 r->headers_out.last_modified_time = ngx_file_mtime(r->file.info);
264 265
265 ngx_test_null(r->headers_out.content_type, 266 if (!(r->headers_out.content_type =
266 ngx_push_table(r->headers_out.headers), 267 ngx_http_add_header(&r->headers_out, ngx_http_headers_out)))
267 NGX_HTTP_INTERNAL_SERVER_ERROR); 268 {
269 return NGX_HTTP_INTERNAL_SERVER_ERROR;
270 }
268 271
269 r->headers_out.content_type->key.len = 0; 272 r->headers_out.content_type->key.len = 0;
270 r->headers_out.content_type->key.data = NULL; 273 r->headers_out.content_type->key.data = NULL;
271 r->headers_out.content_type->value.len = 0; 274 r->headers_out.content_type->value.len = 0;
272 r->headers_out.content_type->value.data = NULL; 275 r->headers_out.content_type->value.data = NULL;