Mercurial > hg > nginx
comparison src/http/modules/ngx_http_index_module.c @ 2160:e21f3b073843
consider log_not_found while testing index files
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 11 Aug 2008 15:22:40 +0000 |
parents | 25add486e7aa |
children | 774bef502c78 |
comparison
equal
deleted
inserted
replaced
2159:0ec936b0010a | 2160:e21f3b073843 |
---|---|
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); |
225 if (of.err == 0) { | 225 if (of.err == 0) { |
226 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 226 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
227 } | 227 } |
228 | 228 |
229 if (of.err == NGX_ENOTDIR || of.err == NGX_EACCES) { | 229 if (of.err == NGX_ENOTDIR || of.err == NGX_EACCES) { |
230 return ngx_http_index_error(r, path.data, of.err); | 230 return ngx_http_index_error(r, clcf, path.data, of.err); |
231 } | 231 } |
232 | 232 |
233 if (!dir_tested) { | 233 if (!dir_tested) { |
234 rc = ngx_http_index_test_dir(r, clcf, path.data, name - 1); | 234 rc = ngx_http_index_test_dir(r, clcf, path.data, name - 1); |
235 | 235 |
304 { | 304 { |
305 if (of.err) { | 305 if (of.err) { |
306 | 306 |
307 if (of.err == NGX_ENOENT) { | 307 if (of.err == NGX_ENOENT) { |
308 *last = c; | 308 *last = c; |
309 return ngx_http_index_error(r, dir.data, NGX_ENOENT); | 309 return ngx_http_index_error(r, clcf, dir.data, NGX_ENOENT); |
310 } | 310 } |
311 | 311 |
312 ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err, | 312 ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err, |
313 ngx_open_file_n " \"%s\" failed", dir.data); | 313 ngx_open_file_n " \"%s\" failed", dir.data); |
314 } | 314 } |
328 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 328 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
329 } | 329 } |
330 | 330 |
331 | 331 |
332 static ngx_int_t | 332 static ngx_int_t |
333 ngx_http_index_error(ngx_http_request_t *r, u_char *file, ngx_err_t err) | 333 ngx_http_index_error(ngx_http_request_t *r, ngx_http_core_loc_conf_t *clcf, |
334 u_char *file, ngx_err_t err) | |
334 { | 335 { |
335 if (err == NGX_EACCES) { | 336 if (err == NGX_EACCES) { |
336 ngx_log_error(NGX_LOG_ERR, r->connection->log, err, | 337 ngx_log_error(NGX_LOG_ERR, r->connection->log, err, |
337 "\"%s\" is forbidden", file); | 338 "\"%s\" is forbidden", file); |
338 | 339 |
339 return NGX_HTTP_FORBIDDEN; | 340 return NGX_HTTP_FORBIDDEN; |
340 } | 341 } |
341 | 342 |
342 ngx_log_error(NGX_LOG_ERR, r->connection->log, err, | 343 if (clcf->log_not_found) { |
343 "\"%s\" is not found", file); | 344 ngx_log_error(NGX_LOG_ERR, r->connection->log, err, |
345 "\"%s\" is not found", file); | |
346 } | |
344 | 347 |
345 return NGX_HTTP_NOT_FOUND; | 348 return NGX_HTTP_NOT_FOUND; |
346 } | 349 } |
347 | 350 |
348 | 351 |