Mercurial > hg > nginx
diff src/http/modules/ngx_http_static_handler.c @ 183:4c698194c56d
nginx-0.0.1-2003-11-13-19:16:33 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 13 Nov 2003 16:16:33 +0000 |
parents | 4db54fdbcbe7 |
children | d5f50cefc322 |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_static_handler.c +++ b/src/http/modules/ngx_http_static_handler.c @@ -87,30 +87,52 @@ ngx_log_debug(r->connection->log, "HTTP #if (WIN9X) - /* - * 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 - */ + if (ngx_win32_version < NGX_WIN_NT) { + + /* + * 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. + */ + + r->file.info.dwFileAttributes = GetFileAttributes(r->file.name.data); + if (r->file.info.dwFileAttributes == INVALID_FILE_ATTRIBUTES) { + err = ngx_errno; + ngx_log_error(NGX_LOG_ERR, r->connection->log, err, + ngx_file_type_n " \"%s\" failed", r->file.name.data); + + if (err == NGX_ENOENT || err == NGX_ENOTDIR) { + return NGX_HTTP_NOT_FOUND; + + } else if (err == NGX_EACCES) { + return NGX_HTTP_FORBIDDEN; - r->file.info.dwFileAttributes = GetFileAttributes(r->file.name.data); - if (r->file.info.dwFileAttributes == INVALID_FILE_ATTRIBUTES) { - err = ngx_errno; - ngx_log_error(NGX_LOG_ERR, r->connection->log, err, - ngx_file_type_n " \"%s\" failed", r->file.name.data); + } else { + return NGX_HTTP_INTERNAL_SERVER_ERROR; + } + } + + if (ngx_is_dir(r->file.info)) { +ngx_log_debug(r->connection->log, "HTTP DIR: '%s'" _ r->file.name.data); - if (err == NGX_ENOENT || err == NGX_ENOTDIR) { - return NGX_HTTP_NOT_FOUND; + if (!(r->headers_out.location = + ngx_http_add_header(&r->headers_out, ngx_http_headers_out))) + { + return NGX_HTTP_INTERNAL_SERVER_ERROR; + } - } else if (err == NGX_EACCES) { - return NGX_HTTP_FORBIDDEN; + *last++ = '/'; + *last = '\0'; + r->headers_out.location->key.len = 8; + r->headers_out.location->key.data = "Location" ; + r->headers_out.location->value.len = last - location; + r->headers_out.location->value.data = location; - } else { - return NGX_HTTP_INTERNAL_SERVER_ERROR; + return NGX_HTTP_MOVED_PERMANENTLY; } } -#else +#endif if (r->file.fd == NGX_INVALID_FILE) { r->file.fd = ngx_open_file(r->file.name.data, @@ -163,7 +185,6 @@ ngx_log_debug(r->connection->log, "FILE: if (ngx_is_dir(r->file.info)) { ngx_log_debug(r->connection->log, "HTTP DIR: '%s'" _ r->file.name.data); -#if !(WIN9X) 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); @@ -171,7 +192,6 @@ ngx_log_debug(r->connection->log, "HTTP r->file.fd = NGX_INVALID_FILE; r->file.info_valid = 0; -#endif if (!(r->headers_out.location = ngx_http_add_header(&r->headers_out, ngx_http_headers_out))) @@ -203,7 +223,6 @@ ngx_log_debug(r->connection->log, "HTTP } #endif -#endif r->content_handler = ngx_http_static_handler;