Mercurial > hg > nginx-quic
diff src/http/modules/ngx_http_static_handler.c @ 87:5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 13 May 2003 16:02:32 +0000 |
parents | 17ab1af8c3dd |
children | 674d333f4296 |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_static_handler.c +++ b/src/http/modules/ngx_http_static_handler.c @@ -1,6 +1,6 @@ #include <ngx_config.h> - +#include <ngx_core.h> #include <ngx_string.h> #include <ngx_file.h> #include <ngx_hunk.h> @@ -14,9 +14,9 @@ ngx_http_module_t ngx_http_static_modul int ngx_http_static_handler(ngx_http_request_t *r) { - int rc; - ngx_err_t err; - ngx_hunk_t *h; + int rc; + ngx_err_t err; + ngx_hunk_t *h; ngx_http_log_ctx_t *ctx; #if 0 @@ -40,10 +40,7 @@ int ngx_http_static_handler(ngx_http_req "ngx_http_static_handler: " ngx_open_file_n " %s failed", r->file.name.data); - if (err == NGX_ENOENT) { - return NGX_HTTP_NOT_FOUND; - - } else if (err == NGX_ENOTDIR) { + if (err == NGX_ENOENT || err == NGX_ENOTDIR) { return NGX_HTTP_NOT_FOUND; } else { @@ -126,11 +123,10 @@ int ngx_http_static_handler(ngx_http_req ngx_test_null(h->file, ngx_pcalloc(r->pool, sizeof(ngx_file_t)), NGX_HTTP_INTERNAL_SERVER_ERROR); - rc = ngx_http_send_header(r); + ngx_http_send_header(r); if (r->header_only) - return rc; + return NGX_OK; -#if 1 h->type = NGX_HUNK_FILE|NGX_HUNK_LAST; h->file_pos = 0; @@ -141,44 +137,14 @@ int ngx_http_static_handler(ngx_http_req rc = ngx_http_output_filter(r, h); - ngx_log_debug(r->connection->log, "0 output_filter: %d" _ rc); - -#else - -#define BLK 10000 - - { - int i, s; - s = ngx_file_size(r->file.info); - - for (i = 0; i < s; i += BLK) { - ngx_test_null(h, ngx_pcalloc(r->pool, sizeof(ngx_hunk_t)), - NGX_HTTP_INTERNAL_SERVER_ERROR); - - ngx_test_null(h->file, ngx_pcalloc(r->pool, sizeof(ngx_file_t)), - NGX_HTTP_INTERNAL_SERVER_ERROR); + if (r->main == NULL) { + if (rc == NGX_AGAIN) { + ngx_http_set_write_handler(r); - h->type = NGX_HUNK_FILE; - if (s - i <= BLK) { - h->type |= NGX_HUNK_LAST; + } else { + ngx_http_finalize_request(r, 0); } - - h->pos.file = i; - h->last.file = i + BLK; - if (h->last.file > s) { - h->last.file = s; - } - - h->file->fd = r->file.fd; - h->file->log = r->connection->log; - - rc = ngx_http_output_filter(r, h); - - ngx_log_debug(r->connection->log, "0 output_filter: %d" _ rc); - } } -#endif - - return rc; + return NGX_OK; }