Mercurial > hg > nginx-quic
comparison src/http/modules/ngx_http_static_handler.c @ 1:d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 15 Aug 2002 17:20:26 +0000 |
parents | |
children | 34a521b1a148 |
comparison
equal
deleted
inserted
replaced
0:4eff17414a43 | 1:d220029ac7f3 |
---|---|
1 | |
2 #include <ngx_config.h> | |
3 | |
4 #include <ngx_strings.h> | |
5 #include <ngx_open.h> | |
6 #include <ngx_stat.h> | |
7 | |
8 #include <ngx_http.h> | |
9 | |
10 int ngx_http_static_handler(ngx_http_request_t *r) | |
11 { | |
12 int index_len, err, i; | |
13 char *name, *loc, *file | |
14 ngx_file_t fd; | |
15 | |
16 ngx_http_header_out_t out; | |
17 ngx_http_event_static_handler_loc_conf_t *cf; | |
18 | |
19 cf = (ngx_http_event_static_handler_loc_conf_t *) | |
20 ngx_get_module_loc_conf(r, &ngx_http_event_static_handler_module); | |
21 | |
22 ngx_assert(r->fd, return NGX_HTTP_INTERNAL_SERVER_ERROR, | |
23 r->connection->log, "ngx_http_static_handler: no file"); | |
24 | |
25 out.status = NGX_HTTP_OK; | |
26 out.content_length = r->stat.sb_size; | |
27 out.last_modified = r->stat.sb_mtime; | |
28 | |
29 /* */ | |
30 out.content_type = "text/html"; | |
31 | |
32 rc = ngx_send_http_header(&out); | |
33 if (r->header_only) | |
34 return rc; | |
35 | |
36 /* NGX_HTTP_INTERNAL_SERVER_ERROR is too late */ | |
37 | |
38 ngx_test_null(h, ngx_create_hunk(r->pool), NGX_HTTP_INTERNAL_SERVER_ERROR); | |
39 h->type = NGX_HUNK_FILE | NGX_HUNK_LAST; | |
40 h->fd = r->fd; | |
41 h->pos.file = 0; | |
42 h->end.file = r->stat.sb_size; | |
43 | |
44 ngx_test_null(ch, ngx_create_chain(r->pool), | |
45 NGX_HTTP_INTERNAL_SERVER_ERROR); | |
46 ch->hunk = h; | |
47 ch->next = NULL; | |
48 | |
49 return ngx_http_filter(ch); | |
50 } | |
51 | |
52 /* | |
53 | |
54 static void *ngx_create_index_config() | |
55 { | |
56 ngx_http_index_handler_loc_conf_t *cf; | |
57 | |
58 ngx_check_null(cf, ngx_alloc(p, sizeof(ngx_http_index_handler_loc_conf)), | |
59 NULL); | |
60 | |
61 cf->indices = ngx_create_array(p, sizeof(ngx_http_index_t), 5); | |
62 if (cf->indices == NULL) | |
63 return NULL; | |
64 | |
65 cf->max_index_len = 0; | |
66 | |
67 return cf; | |
68 } | |
69 | |
70 static void *ngx_merge_index_config() | |
71 { | |
72 if (p->indices->nelts > 0) { | |
73 | |
74 copy and check dups | |
75 | |
76 if (c->max_index_len < c->max_index_len) | |
77 c->max_index_len < c->max_index_len); | |
78 } | |
79 } | |
80 | |
81 static void *ngx_set_index() | |
82 { | |
83 if (*conf == NULL) { | |
84 cf = ngx_create_index_conf(); | |
85 if (cf == NULL) | |
86 return "can not create config"; | |
87 } | |
88 | |
89 while (args) { | |
90 index = ngx_push_array(cf->indices); | |
91 index->name = arg; | |
92 index->len = ngx_strlen(arg) + 1; | |
93 | |
94 if (cf->max_index_len < index->len) | |
95 cf->max_index_len = index->len; | |
96 } | |
97 | |
98 *conf = cf; | |
99 } | |
100 | |
101 */ |