Mercurial > hg > nginx-quic
comparison src/http/modules/ngx_http_static_handler.c @ 197:0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 27 Nov 2003 07:45:22 +0000 |
parents | 8dee38ea9117 |
children | a65b630b3a66 |
comparison
equal
deleted
inserted
replaced
196:11fbd0fc041d | 197:0b81c7a0b133 |
---|---|
37 ngx_http_static_init, /* init module */ | 37 ngx_http_static_init, /* init module */ |
38 NULL /* init child */ | 38 NULL /* init child */ |
39 }; | 39 }; |
40 | 40 |
41 | 41 |
42 int ngx_http_static_translate_handler(ngx_http_request_t *r) | 42 ngx_int_t ngx_http_static_translate_handler(ngx_http_request_t *r) |
43 { | 43 { |
44 int rc, level; | 44 ngx_int_t rc, level; |
45 uint32_t crc; | |
45 char *location, *last; | 46 char *location, *last; |
46 ngx_err_t err; | 47 ngx_err_t err; |
47 ngx_http_cache_ctx_t ctx; | 48 ngx_http_cache_t *cache; |
48 ngx_http_cache_conf_t *ccf; | 49 ngx_http_cache_conf_t *ccf; |
49 ngx_http_core_loc_conf_t *clcf; | 50 ngx_http_core_loc_conf_t *clcf; |
50 | 51 |
51 if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) { | 52 if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) { |
52 return NGX_HTTP_NOT_ALLOWED; | 53 return NGX_HTTP_NOT_ALLOWED; |
85 | 86 |
86 last = ngx_cpystrn(location, r->uri.data, r->uri.len + 1); | 87 last = ngx_cpystrn(location, r->uri.data, r->uri.len + 1); |
87 | 88 |
88 ngx_log_debug(r->connection->log, "HTTP filename: '%s'" _ r->file.name.data); | 89 ngx_log_debug(r->connection->log, "HTTP filename: '%s'" _ r->file.name.data); |
89 | 90 |
90 | |
91 /* STUB */ | |
92 ccf = NULL; | |
93 ctx.key.len = 0; | |
94 | |
95 #if 0 | |
96 ccf = ngx_http_get_module_loc_conf(r, ngx_http_cache_module); | 91 ccf = ngx_http_get_module_loc_conf(r, ngx_http_cache_module); |
97 | 92 |
98 if (ccf->open_files) { | 93 if (ccf->open_files) { |
99 ctx->hash = ccf->open_files; | 94 cache = ngx_http_cache_get(ccf->open_files, &r->file.name, &crc); |
100 ctx->key = r->file.name; | 95 |
101 | 96 ngx_log_debug(r->connection->log, "cache get: %x" _ cache); |
102 cache = ngx_http_cache_get_data(r, ctx); | |
103 | 97 |
104 if (cache | 98 if (cache |
105 && ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) | 99 && ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) |
106 || ccf->hash->life_time >= ngx_time() - cache->updated)) | 100 || ccf->open_files->check_time >= ngx_time() - cache->updated)) |
107 { | 101 { |
108 cache->refs++; | 102 cache->refs++; |
109 r->file.fd = cache->fd; | 103 r->file.fd = cache->fd; |
110 r->file.name = cache->key; | 104 r->file.name = cache->key; |
111 r->content_handler = ngx_http_static_handler; | 105 r->content_handler = ngx_http_static_handler; |
114 } | 108 } |
115 | 109 |
116 } else { | 110 } else { |
117 cache = NULL; | 111 cache = NULL; |
118 } | 112 } |
119 | |
120 #endif | |
121 | 113 |
122 #if (WIN9X) | 114 #if (WIN9X) |
123 | 115 |
124 if (ngx_win32_version < NGX_WIN_NT) { | 116 if (ngx_win32_version < NGX_WIN_NT) { |
125 | 117 |
211 | 203 |
212 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 204 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
213 } | 205 } |
214 | 206 |
215 r->file.info_valid = 1; | 207 r->file.info_valid = 1; |
208 } | |
209 | |
210 if (ccf->open_files) { | |
211 if (cache == NULL) { | |
212 cache = ngx_http_cache_alloc(ccf->open_files, &r->file.name, crc, | |
213 r->connection->log); | |
214 } | |
215 | |
216 ngx_log_debug(r->connection->log, "cache alloc: %x" _ cache); | |
217 | |
218 if (cache) { | |
219 cache->fd = r->file.fd; | |
220 cache->data.size = ngx_file_size(&r->file.info); | |
221 cache->accessed = ngx_time(); | |
222 cache->last_modified = ngx_file_mtime(&r->file.info); | |
223 cache->updated = ngx_time(); | |
224 } | |
216 } | 225 } |
217 | 226 |
218 if (ngx_is_dir(&r->file.info)) { | 227 if (ngx_is_dir(&r->file.info)) { |
219 ngx_log_debug(r->connection->log, "HTTP DIR: '%s'" _ r->file.name.data); | 228 ngx_log_debug(r->connection->log, "HTTP DIR: '%s'" _ r->file.name.data); |
220 | 229 |