Mercurial > hg > nginx
comparison src/http/ngx_http_core_module.c @ 45:f1ee46c036a4
nginx-0.0.1-2003-01-10-09:09:20 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 10 Jan 2003 06:09:20 +0000 |
parents | 0e81ac0bb3e2 |
children | f84a648211f4 |
comparison
equal
deleted
inserted
replaced
44:0e81ac0bb3e2 | 45:f1ee46c036a4 |
---|---|
9 #include <ngx_http_core_module.h> | 9 #include <ngx_http_core_module.h> |
10 | 10 |
11 #if 0 | 11 #if 0 |
12 #include <ngx_http_write_filter.h> | 12 #include <ngx_http_write_filter.h> |
13 #include <ngx_http_output_filter.h> | 13 #include <ngx_http_output_filter.h> |
14 #include <ngx_http_index_handler.h> | |
15 #endif | 14 #endif |
16 | 15 |
17 /* STUB */ | 16 /* STUB */ |
18 #include <ngx_http_output_filter.h> | 17 #include <ngx_http_output_filter.h> |
19 int ngx_http_static_handler(ngx_http_request_t *r); | 18 int ngx_http_static_handler(ngx_http_request_t *r); |
20 int ngx_http_index_handler(ngx_http_request_t *r); | |
21 int ngx_http_proxy_handler(ngx_http_request_t *r); | 19 int ngx_http_proxy_handler(ngx_http_request_t *r); |
22 /**/ | 20 /**/ |
21 | |
22 static int ngx_http_core_index_handler(ngx_http_request_t *r); | |
23 | 23 |
24 | 24 |
25 static char *ngx_server_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy); | 25 static char *ngx_server_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy); |
26 static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, | 26 static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, |
27 char *dummy); | 27 char *dummy); |
171 r->loc_conf = lcf[i]->loc_conf; | 171 r->loc_conf = lcf[i]->loc_conf; |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
175 if (r->uri.data[r->uri.len - 1] == '/') { | 175 if (r->uri.data[r->uri.len - 1] == '/') { |
176 /* TODO: find index handler */ | 176 r->handler = ngx_http_core_index_handler; |
177 /* STUB */ r->handler = ngx_http_index_handler; | |
178 | |
179 return NGX_OK; | 177 return NGX_OK; |
180 } | 178 } |
181 | 179 |
182 loc_conf = (ngx_http_core_loc_conf_t *) | 180 loc_conf = (ngx_http_core_loc_conf_t *) |
183 ngx_http_get_module_loc_conf(r, ngx_http_core_module_ctx); | 181 ngx_http_get_module_loc_conf(r, ngx_http_core_module_ctx); |
231 | 229 |
232 if (err == NGX_ENOENT) { | 230 if (err == NGX_ENOENT) { |
233 return NGX_HTTP_NOT_FOUND; | 231 return NGX_HTTP_NOT_FOUND; |
234 #if (WIN32) | 232 #if (WIN32) |
235 } else if (err == ERROR_PATH_NOT_FOUND) { | 233 } else if (err == ERROR_PATH_NOT_FOUND) { |
234 return NGX_HTTP_NOT_FOUND; | |
235 #else | |
236 } else if (err == NGX_ENOTDIR) { | |
236 return NGX_HTTP_NOT_FOUND; | 237 return NGX_HTTP_NOT_FOUND; |
237 #endif | 238 #endif |
238 } else { | 239 } else { |
239 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 240 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
240 } | 241 } |
288 | 289 |
289 /* TODO: r->handler = loc_conf->default_handler; */ | 290 /* TODO: r->handler = loc_conf->default_handler; */ |
290 /* STUB */ r->handler = ngx_http_static_handler; | 291 /* STUB */ r->handler = ngx_http_static_handler; |
291 | 292 |
292 return NGX_OK; | 293 return NGX_OK; |
294 } | |
295 | |
296 | |
297 static int ngx_http_core_index_handler(ngx_http_request_t *r) | |
298 { | |
299 int i, rc; | |
300 ngx_err_t err; | |
301 ngx_http_handler_pt *h; | |
302 | |
303 h = (ngx_http_handler_pt *) ngx_http_index_handlers.elts; | |
304 for (i = 0; i < ngx_http_index_handlers.nelts; i++) { | |
305 rc = h[i](r); | |
306 | |
307 if (rc != NGX_DECLINED) { | |
308 return rc; | |
309 } | |
310 } | |
311 | |
312 #if (WIN32) | |
313 | |
314 if (r->path_not_found) { | |
315 return NGX_HTTP_NOT_FOUND; | |
316 | |
317 } else { | |
318 return NGX_HTTP_FORBIDDEN; | |
319 } | |
320 | |
321 #else | |
322 | |
323 if (r->path_not_found) { | |
324 return NGX_HTTP_NOT_FOUND; | |
325 } | |
326 | |
327 r->path.data[r->path.len] = '\0'; | |
328 if (stat(r->path.data, &r->file.info) == -1) { | |
329 | |
330 err = ngx_errno; | |
331 if (err == NGX_ENOENT) { | |
332 return NGX_HTTP_NOT_FOUND; | |
333 } | |
334 | |
335 ngx_log_error(NGX_LOG_ERR, r->connection->log, err, | |
336 "ngx_http_core_index_handler: " | |
337 "stat() %s failed", r->path.data); | |
338 | |
339 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
340 } | |
341 | |
342 if (ngx_is_dir(r->file.info)) { | |
343 return NGX_HTTP_FORBIDDEN; | |
344 | |
345 } else { | |
346 return NGX_HTTP_NOT_FOUND; | |
347 } | |
348 | |
349 #endif | |
293 } | 350 } |
294 | 351 |
295 | 352 |
296 int ngx_http_send_header(ngx_http_request_t *r) | 353 int ngx_http_send_header(ngx_http_request_t *r) |
297 { | 354 { |