aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/ngx_http_static_handler.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2003-05-13 16:02:32 +0000
committerIgor Sysoev <igor@sysoev.ru>2003-05-13 16:02:32 +0000
commitd581fd58e11724df8d7a9d748f9fc3ab66911a5f (patch)
tree2e72949423b332fd6d4c48da6f1a7fe02f7fbddf /src/http/modules/ngx_http_static_handler.c
parent6b863e353d54420c323d67f86aad0b90ba04e316 (diff)
downloadnginx-d581fd58e11724df8d7a9d748f9fc3ab66911a5f.tar.gz
nginx-d581fd58e11724df8d7a9d748f9fc3ab66911a5f.zip
nginx-0.0.1-2003-05-13-20:02:32 import
Diffstat (limited to 'src/http/modules/ngx_http_static_handler.c')
-rw-r--r--src/http/modules/ngx_http_static_handler.c60
1 files changed, 13 insertions, 47 deletions
diff --git a/src/http/modules/ngx_http_static_handler.c b/src/http/modules/ngx_http_static_handler.c
index 480e641a3..69c1d2956 100644
--- 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_module;
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_request_t *r)
"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_request_t *r)
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_request_t *r)
rc = ngx_http_output_filter(r, h);
- ngx_log_debug(r->connection->log, "0 output_filter: %d" _ rc);
-
-#else
-
-#define BLK 10000
+ if (r->main == NULL) {
+ if (rc == NGX_AGAIN) {
+ ngx_http_set_write_handler(r);
- {
- 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);
-
- h->type = NGX_HUNK_FILE;
- if (s - i <= BLK) {
- h->type |= NGX_HUNK_LAST;
- }
-
- h->pos.file = i;
- h->last.file = i + BLK;
- if (h->last.file > s) {
- h->last.file = s;
+ } else {
+ ngx_http_finalize_request(r, 0);
}
-
- 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;
}