aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/ngx_http_static_handler.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2002-09-02 14:48:24 +0000
committerIgor Sysoev <igor@sysoev.ru>2002-09-02 14:48:24 +0000
commita58e3ca14300fce97b2124233afe140c8d59199f (patch)
treed24eff379cc7dfb5c6952f1bb15735cd63ba2179 /src/http/modules/ngx_http_static_handler.c
parent016b85270268989d769bade2004a7c628a47d726 (diff)
downloadnginx-a58e3ca14300fce97b2124233afe140c8d59199f.tar.gz
nginx-a58e3ca14300fce97b2124233afe140c8d59199f.zip
nginx-0.0.1-2002-09-02-18:48:24 import
Diffstat (limited to 'src/http/modules/ngx_http_static_handler.c')
-rw-r--r--src/http/modules/ngx_http_static_handler.c47
1 files changed, 17 insertions, 30 deletions
diff --git a/src/http/modules/ngx_http_static_handler.c b/src/http/modules/ngx_http_static_handler.c
index 20d0b9e5f..0900a42cf 100644
--- a/src/http/modules/ngx_http_static_handler.c
+++ b/src/http/modules/ngx_http_static_handler.c
@@ -26,7 +26,7 @@ int ngx_http_static_handler(ngx_http_request_t *r)
{
int rc;
ngx_hunk_t *h;
- ngx_chain_t *ch;
+ ngx_http_log_ctx_t *ctx;
/*
ngx_http_event_static_handler_loc_conf_t *cf;
@@ -36,6 +36,10 @@ int ngx_http_static_handler(ngx_http_request_t *r)
*/
+ ngx_http_discard_body(r);
+ ctx = r->connection->log->data;
+ ctx->action = "sending response";
+
r->fd = ngx_open_file(r->filename, NGX_FILE_RDONLY);
if (r->fd == -1) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, ngx_errno,
@@ -45,7 +49,7 @@ int ngx_http_static_handler(ngx_http_request_t *r)
return -1;
}
- if (ngx_stat_fd(r->fd, &r->file_info) == -1) {
+ if (ngx_stat_fd(r->fd, &r->fileinfo) == -1) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, ngx_errno,
"ngx_http_static_handler: "
ngx_stat_fd_n " %s failed", r->filename);
@@ -54,9 +58,9 @@ int ngx_http_static_handler(ngx_http_request_t *r)
}
r->headers_out->status = NGX_HTTP_OK;
- r->headers_out->content_length = ngx_file_size(r->file_info);
+ r->headers_out->content_length = ngx_file_size(r->fileinfo);
/*
- r->headers_out->last_modified = ngx_file_mtime(r->file_info);
+ r->headers_out->last_modified = ngx_file_mtime(r->fileinfo);
*/
/* STUB */
@@ -73,39 +77,22 @@ int ngx_http_static_handler(ngx_http_request_t *r)
/* TODO: NGX_HTTP_INTERNAL_SERVER_ERROR is too late */
/* STUB */
- ngx_test_null(h, ngx_get_hunk(r->pool, 1024, 0, 64),
- /* STUB */
- -1);
-/*
- ngx_test_null(h, ngx_create_hunk(r->pool), NGX_HTTP_INTERNAL_SERVER_ERROR);
-*/
+ ngx_test_null(h, ngx_pcalloc(r->pool, sizeof(ngx_hunk_t)),
+ NGX_HTTP_INTERNAL_SERVER_ERROR);
+
h->type = NGX_HUNK_FILE|NGX_HUNK_LAST;
- h->fd = r->fd;
h->pos.file = 0;
- h->last.file = ngx_file_size(r->file_info);
+ h->last.file = ngx_file_size(r->fileinfo);
/* STUB */
- ngx_test_null(ch, ngx_palloc(r->pool, sizeof(ngx_chain_t)),
- /* STUB */
- -1);
-/*
- NGX_HTTP_FILTER_ERROR);
-*/
-
-/*
- ngx_test_null(ch, ngx_create_chain(r->pool),
+ ngx_test_null(h->file, ngx_pcalloc(r->pool, sizeof(ngx_file_t)),
NGX_HTTP_INTERNAL_SERVER_ERROR);
-*/
- ch->hunk = h;
- ch->next = NULL;
+ h->file->fd = r->fd;
+ h->file->log = r->connection->log;
- /* STUB */
- rc = ngx_http_write_filter(r, ch);
- ngx_log_debug(r->connection->log, "write_filter: %d" _ rc);
+ rc = ngx_http_output_filter(r, h);
+ ngx_log_debug(r->connection->log, "0 output_filter: %d" _ rc);
return rc;
-/*
- return ngx_http_filter(r, ch);
-*/
}
#if 0