Mercurial > hg > nginx-quic
comparison src/http/modules/ngx_http_static_handler.c @ 185:d5f50cefc322
nginx-0.0.1-2003-11-14-19:52:04 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 14 Nov 2003 16:52:04 +0000 |
parents | 4c698194c56d |
children | c1f3a3c7c5db |
comparison
equal
deleted
inserted
replaced
184:1bf718ce0dde | 185:d5f50cefc322 |
---|---|
88 #if (WIN9X) | 88 #if (WIN9X) |
89 | 89 |
90 if (ngx_win32_version < NGX_WIN_NT) { | 90 if (ngx_win32_version < NGX_WIN_NT) { |
91 | 91 |
92 /* | 92 /* |
93 * There is no way to open a file or a directory in Win9X with | 93 * there is no way to open a file or a directory in Win9X with |
94 * one syscall: Win9X has no FILE_FLAG_BACKUP_SEMANTICS flag. | 94 * one syscall because Win9X has no FILE_FLAG_BACKUP_SEMANTICS flag |
95 * So we need to check its type before the opening. | 95 * so we need to check its type before the opening |
96 */ | 96 */ |
97 | 97 |
98 r->file.info.dwFileAttributes = GetFileAttributes(r->file.name.data); | 98 if (ngx_file_type(r->file.name.data, &r->file.info) == NGX_FILE_ERROR) { |
99 if (r->file.info.dwFileAttributes == INVALID_FILE_ATTRIBUTES) { | |
100 err = ngx_errno; | 99 err = ngx_errno; |
101 ngx_log_error(NGX_LOG_ERR, r->connection->log, err, | 100 ngx_log_error(NGX_LOG_ERR, r->connection->log, err, |
102 ngx_file_type_n " \"%s\" failed", r->file.name.data); | 101 ngx_file_type_n " \"%s\" failed", r->file.name.data); |
103 | 102 |
104 if (err == NGX_ENOENT || err == NGX_ENOTDIR) { | 103 if (err == NGX_ENOENT || err == NGX_ENOTDIR) { |
180 } | 179 } |
181 | 180 |
182 r->file.info_valid = 1; | 181 r->file.info_valid = 1; |
183 } | 182 } |
184 | 183 |
185 if (ngx_is_dir(r->file.info)) { | 184 if (ngx_is_dir((&r->file.info))) { |
186 ngx_log_debug(r->connection->log, "HTTP DIR: '%s'" _ r->file.name.data); | 185 ngx_log_debug(r->connection->log, "HTTP DIR: '%s'" _ r->file.name.data); |
187 | 186 |
188 if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) { | 187 if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) { |
189 ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno, | 188 ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno, |
190 ngx_close_file_n " \"%s\" failed", r->file.name.data); | 189 ngx_close_file_n " \"%s\" failed", r->file.name.data); |
209 return NGX_HTTP_MOVED_PERMANENTLY; | 208 return NGX_HTTP_MOVED_PERMANENTLY; |
210 } | 209 } |
211 | 210 |
212 #if !(WIN32) /* the not regular files are probably Unix specific */ | 211 #if !(WIN32) /* the not regular files are probably Unix specific */ |
213 | 212 |
214 if (!ngx_is_file(r->file.info)) { | 213 if (!ngx_is_file((&r->file.info))) { |
215 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, | 214 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, |
216 "%s is not a regular file", r->file.name.data); | 215 "%s is not a regular file", r->file.name.data); |
217 | 216 |
218 if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) | 217 if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) |
219 ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno, | 218 ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno, |
286 | 285 |
287 r->file.info_valid = 1; | 286 r->file.info_valid = 1; |
288 } | 287 } |
289 | 288 |
290 r->headers_out.status = NGX_HTTP_OK; | 289 r->headers_out.status = NGX_HTTP_OK; |
291 r->headers_out.content_length_n = ngx_file_size(r->file.info); | 290 r->headers_out.content_length_n = ngx_file_size((&r->file.info)); |
292 r->headers_out.last_modified_time = ngx_file_mtime(r->file.info); | 291 r->headers_out.last_modified_time = ngx_file_mtime((&r->file.info)); |
293 | 292 |
294 if (!(r->headers_out.content_type = | 293 if (!(r->headers_out.content_type = |
295 ngx_http_add_header(&r->headers_out, ngx_http_headers_out))) | 294 ngx_http_add_header(&r->headers_out, ngx_http_headers_out))) |
296 { | 295 { |
297 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 296 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
343 } | 342 } |
344 | 343 |
345 h->type = r->main ? NGX_HUNK_FILE : NGX_HUNK_FILE|NGX_HUNK_LAST; | 344 h->type = r->main ? NGX_HUNK_FILE : NGX_HUNK_FILE|NGX_HUNK_LAST; |
346 | 345 |
347 h->file_pos = 0; | 346 h->file_pos = 0; |
348 h->file_last = ngx_file_size(r->file.info); | 347 h->file_last = ngx_file_size((&r->file.info)); |
349 | 348 |
350 h->file->fd = r->file.fd; | 349 h->file->fd = r->file.fd; |
351 h->file->log = r->connection->log; | 350 h->file->log = r->connection->log; |
352 | 351 |
353 out.hunk = h; | 352 out.hunk = h; |