Mercurial > hg > nginx
comparison src/http/modules/ngx_http_static_handler.c @ 8:708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 02 Sep 2002 14:48:24 +0000 |
parents | 34a521b1a148 |
children | 4f3879d9b6f6 |
comparison
equal
deleted
inserted
replaced
7:b5481d6fbbd4 | 8:708f8bb772ec |
---|---|
24 | 24 |
25 int ngx_http_static_handler(ngx_http_request_t *r) | 25 int ngx_http_static_handler(ngx_http_request_t *r) |
26 { | 26 { |
27 int rc; | 27 int rc; |
28 ngx_hunk_t *h; | 28 ngx_hunk_t *h; |
29 ngx_chain_t *ch; | 29 ngx_http_log_ctx_t *ctx; |
30 | 30 |
31 /* | 31 /* |
32 ngx_http_event_static_handler_loc_conf_t *cf; | 32 ngx_http_event_static_handler_loc_conf_t *cf; |
33 | 33 |
34 cf = (ngx_http_event_static_handler_loc_conf_t *) | 34 cf = (ngx_http_event_static_handler_loc_conf_t *) |
35 ngx_get_module_loc_conf(r, &ngx_http_event_static_handler_module); | 35 ngx_get_module_loc_conf(r, &ngx_http_event_static_handler_module); |
36 | 36 |
37 */ | 37 */ |
38 | |
39 ngx_http_discard_body(r); | |
40 ctx = r->connection->log->data; | |
41 ctx->action = "sending response"; | |
38 | 42 |
39 r->fd = ngx_open_file(r->filename, NGX_FILE_RDONLY); | 43 r->fd = ngx_open_file(r->filename, NGX_FILE_RDONLY); |
40 if (r->fd == -1) { | 44 if (r->fd == -1) { |
41 ngx_log_error(NGX_LOG_ERR, r->connection->log, ngx_errno, | 45 ngx_log_error(NGX_LOG_ERR, r->connection->log, ngx_errno, |
42 "ngx_http_static_handler: " | 46 "ngx_http_static_handler: " |
43 ngx_open_file_n " %s failed", r->filename); | 47 ngx_open_file_n " %s failed", r->filename); |
44 /* STUB */ | 48 /* STUB */ |
45 return -1; | 49 return -1; |
46 } | 50 } |
47 | 51 |
48 if (ngx_stat_fd(r->fd, &r->file_info) == -1) { | 52 if (ngx_stat_fd(r->fd, &r->fileinfo) == -1) { |
49 ngx_log_error(NGX_LOG_ERR, r->connection->log, ngx_errno, | 53 ngx_log_error(NGX_LOG_ERR, r->connection->log, ngx_errno, |
50 "ngx_http_static_handler: " | 54 "ngx_http_static_handler: " |
51 ngx_stat_fd_n " %s failed", r->filename); | 55 ngx_stat_fd_n " %s failed", r->filename); |
52 /* STUB */ | 56 /* STUB */ |
53 return -1; | 57 return -1; |
54 } | 58 } |
55 | 59 |
56 r->headers_out->status = NGX_HTTP_OK; | 60 r->headers_out->status = NGX_HTTP_OK; |
57 r->headers_out->content_length = ngx_file_size(r->file_info); | 61 r->headers_out->content_length = ngx_file_size(r->fileinfo); |
58 /* | 62 /* |
59 r->headers_out->last_modified = ngx_file_mtime(r->file_info); | 63 r->headers_out->last_modified = ngx_file_mtime(r->fileinfo); |
60 */ | 64 */ |
61 | 65 |
62 /* STUB */ | 66 /* STUB */ |
63 r->headers_out->content_type = "text/html"; | 67 r->headers_out->content_type = "text/html"; |
64 | 68 |
71 return rc; | 75 return rc; |
72 | 76 |
73 /* TODO: NGX_HTTP_INTERNAL_SERVER_ERROR is too late */ | 77 /* TODO: NGX_HTTP_INTERNAL_SERVER_ERROR is too late */ |
74 | 78 |
75 /* STUB */ | 79 /* STUB */ |
76 ngx_test_null(h, ngx_get_hunk(r->pool, 1024, 0, 64), | 80 ngx_test_null(h, ngx_pcalloc(r->pool, sizeof(ngx_hunk_t)), |
77 /* STUB */ | 81 NGX_HTTP_INTERNAL_SERVER_ERROR); |
78 -1); | 82 |
79 /* | |
80 ngx_test_null(h, ngx_create_hunk(r->pool), NGX_HTTP_INTERNAL_SERVER_ERROR); | |
81 */ | |
82 h->type = NGX_HUNK_FILE|NGX_HUNK_LAST; | 83 h->type = NGX_HUNK_FILE|NGX_HUNK_LAST; |
83 h->fd = r->fd; | |
84 h->pos.file = 0; | 84 h->pos.file = 0; |
85 h->last.file = ngx_file_size(r->file_info); | 85 h->last.file = ngx_file_size(r->fileinfo); |
86 | 86 |
87 /* STUB */ | 87 /* STUB */ |
88 ngx_test_null(ch, ngx_palloc(r->pool, sizeof(ngx_chain_t)), | 88 ngx_test_null(h->file, ngx_pcalloc(r->pool, sizeof(ngx_file_t)), |
89 /* STUB */ | 89 NGX_HTTP_INTERNAL_SERVER_ERROR); |
90 -1); | 90 h->file->fd = r->fd; |
91 /* | 91 h->file->log = r->connection->log; |
92 NGX_HTTP_FILTER_ERROR); | |
93 */ | |
94 | 92 |
95 /* | 93 rc = ngx_http_output_filter(r, h); |
96 ngx_test_null(ch, ngx_create_chain(r->pool), | 94 ngx_log_debug(r->connection->log, "0 output_filter: %d" _ rc); |
97 NGX_HTTP_INTERNAL_SERVER_ERROR); | |
98 */ | |
99 ch->hunk = h; | |
100 ch->next = NULL; | |
101 | |
102 /* STUB */ | |
103 rc = ngx_http_write_filter(r, ch); | |
104 ngx_log_debug(r->connection->log, "write_filter: %d" _ rc); | |
105 return rc; | 95 return rc; |
106 /* | |
107 return ngx_http_filter(r, ch); | |
108 */ | |
109 } | 96 } |
110 | 97 |
111 #if 0 | 98 #if 0 |
112 | 99 |
113 static void *ngx_create_index_config() | 100 static void *ngx_create_index_config() |