Mercurial > hg > nginx
comparison src/http/modules/ngx_http_index_module.c @ 2352:4521f4615506 stable-0.6
r2161 merge:
consider log_not_found while testing index files
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 27 Nov 2008 14:35:19 +0000 |
parents | 2577098d65ac |
children |
comparison
equal
deleted
inserted
replaced
2351:a60b3fcf25ec | 2352:4521f4615506 |
---|---|
25 #define NGX_HTTP_DEFAULT_INDEX "index.html" | 25 #define NGX_HTTP_DEFAULT_INDEX "index.html" |
26 | 26 |
27 | 27 |
28 static ngx_int_t ngx_http_index_test_dir(ngx_http_request_t *r, | 28 static ngx_int_t ngx_http_index_test_dir(ngx_http_request_t *r, |
29 ngx_http_core_loc_conf_t *clcf, u_char *path, u_char *last); | 29 ngx_http_core_loc_conf_t *clcf, u_char *path, u_char *last); |
30 static ngx_int_t ngx_http_index_error(ngx_http_request_t *r, u_char *file, | 30 static ngx_int_t ngx_http_index_error(ngx_http_request_t *r, |
31 ngx_err_t err); | 31 ngx_http_core_loc_conf_t *clcf, u_char *file, ngx_err_t err); |
32 | 32 |
33 static ngx_int_t ngx_http_index_init(ngx_conf_t *cf); | 33 static ngx_int_t ngx_http_index_init(ngx_conf_t *cf); |
34 static void *ngx_http_index_create_loc_conf(ngx_conf_t *cf); | 34 static void *ngx_http_index_create_loc_conf(ngx_conf_t *cf); |
35 static char *ngx_http_index_merge_loc_conf(ngx_conf_t *cf, | 35 static char *ngx_http_index_merge_loc_conf(ngx_conf_t *cf, |
36 void *parent, void *child); | 36 void *parent, void *child); |
223 if (of.err == 0) { | 223 if (of.err == 0) { |
224 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 224 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
225 } | 225 } |
226 | 226 |
227 if (of.err == NGX_ENOTDIR || of.err == NGX_EACCES) { | 227 if (of.err == NGX_ENOTDIR || of.err == NGX_EACCES) { |
228 return ngx_http_index_error(r, path.data, of.err); | 228 return ngx_http_index_error(r, clcf, path.data, of.err); |
229 } | 229 } |
230 | 230 |
231 if (!dir_tested) { | 231 if (!dir_tested) { |
232 rc = ngx_http_index_test_dir(r, clcf, path.data, name - 1); | 232 rc = ngx_http_index_test_dir(r, clcf, path.data, name - 1); |
233 | 233 |
301 { | 301 { |
302 if (of.err) { | 302 if (of.err) { |
303 | 303 |
304 if (of.err == NGX_ENOENT) { | 304 if (of.err == NGX_ENOENT) { |
305 *last = c; | 305 *last = c; |
306 return ngx_http_index_error(r, dir.data, NGX_ENOENT); | 306 return ngx_http_index_error(r, clcf, dir.data, NGX_ENOENT); |
307 } | 307 } |
308 | 308 |
309 if (of.err == NGX_EACCES) { | 309 if (of.err == NGX_EACCES) { |
310 | 310 |
311 *last = c; | 311 *last = c; |
338 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 338 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
339 } | 339 } |
340 | 340 |
341 | 341 |
342 static ngx_int_t | 342 static ngx_int_t |
343 ngx_http_index_error(ngx_http_request_t *r, u_char *file, ngx_err_t err) | 343 ngx_http_index_error(ngx_http_request_t *r, ngx_http_core_loc_conf_t *clcf, |
344 u_char *file, ngx_err_t err) | |
344 { | 345 { |
345 if (err == NGX_EACCES) { | 346 if (err == NGX_EACCES) { |
346 ngx_log_error(NGX_LOG_ERR, r->connection->log, err, | 347 ngx_log_error(NGX_LOG_ERR, r->connection->log, err, |
347 "\"%s\" is forbidden", file); | 348 "\"%s\" is forbidden", file); |
348 | 349 |
349 return NGX_HTTP_FORBIDDEN; | 350 return NGX_HTTP_FORBIDDEN; |
350 } | 351 } |
351 | 352 |
352 ngx_log_error(NGX_LOG_ERR, r->connection->log, err, | 353 if (clcf->log_not_found) { |
353 "\"%s\" is not found", file); | 354 ngx_log_error(NGX_LOG_ERR, r->connection->log, err, |
355 "\"%s\" is not found", file); | |
356 } | |
354 | 357 |
355 return NGX_HTTP_NOT_FOUND; | 358 return NGX_HTTP_NOT_FOUND; |
356 } | 359 } |
357 | 360 |
358 | 361 |