Mercurial > hg > nginx
diff src/http/modules/ngx_http_static_handler.c @ 160:e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 27 Oct 2003 08:53:49 +0000 |
parents | c71aeb75c071 |
children | 894a01c6aea3 |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_static_handler.c +++ b/src/http/modules/ngx_http_static_handler.c @@ -88,7 +88,7 @@ ngx_log_debug(r->connection->log, "HTTP /* * There is no way to open a file or a directory in Win9X with * one syscall: Win9X has no FILE_FLAG_BACKUP_SEMANTICS flag. - * so we need to check its type before the opening + * So we need to check its type before the opening */ r->file.info.dwFileAttributes = GetFileAttributes(r->file.name.data); @@ -151,6 +151,21 @@ ngx_log_debug(r->connection->log, "FILE: r->file.info_valid = 1; } + +#if !(WIN32) /* the not regular files are probably Unix specific */ + + if (!ngx_is_file(r->file.info)) { + ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, + "%s is not a regular file", r->file.name.data); + + if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) + ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno, + ngx_close_file_n " %s failed", r->file.name.data); + + return NGX_HTTP_NOT_FOUND; + } + +#endif #endif if (ngx_is_dir(r->file.info)) { @@ -163,6 +178,7 @@ ngx_log_debug(r->connection->log, "HTTP } r->file.fd = NGX_INVALID_FILE; + r->file.info_valid = 0; #endif ngx_test_null(h, ngx_push_table(r->headers_out.headers), @@ -203,7 +219,7 @@ static int ngx_http_static_handler(ngx_h } ctx = r->connection->log->data; - ctx->action = "sending response"; + ctx->action = "sending response to client"; if (r->file.fd == NGX_INVALID_FILE) { r->file.fd = ngx_open_file(r->file.name.data, @@ -242,21 +258,6 @@ static int ngx_http_static_handler(ngx_h r->file.info_valid = 1; } -#if !(WIN32) /* the not regular files are probably Unix specific */ - - if (!ngx_is_file(r->file.info)) { - ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, - "%s is not regular file", r->file.name.data); - - if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) - ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno, - ngx_close_file_n " %s failed", r->file.name.data); - - return NGX_HTTP_NOT_FOUND; - } - -#endif - r->headers_out.status = NGX_HTTP_OK; r->headers_out.content_length_n = ngx_file_size(r->file.info); r->headers_out.last_modified_time = ngx_file_mtime(r->file.info);