comparison src/http/modules/ngx_http_static_handler.c @ 287:35a6a9df2d25

nginx-0.0.2-2004-03-12-19:57:08 import
author Igor Sysoev <igor@sysoev.ru>
date Fri, 12 Mar 2004 16:57:08 +0000
parents 70e1c7d2b83d
children f81d075ad172
comparison
equal deleted inserted replaced
286:fc8dc489247e 287:35a6a9df2d25
15 void *parent, void *child); 15 void *parent, void *child);
16 static ngx_int_t ngx_http_static_init(ngx_cycle_t *cycle); 16 static ngx_int_t ngx_http_static_init(ngx_cycle_t *cycle);
17 17
18 18
19 static ngx_command_t ngx_http_static_commands[] = { 19 static ngx_command_t ngx_http_static_commands[] = {
20
21 #if (NGX_HTTP_CACHE)
20 22
21 { ngx_string("redirect_cache"), 23 { ngx_string("redirect_cache"),
22 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE3, 24 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE3,
23 ngx_http_set_cache_slot, 25 ngx_http_set_cache_slot,
24 NGX_HTTP_LOC_CONF_OFFSET, 26 NGX_HTTP_LOC_CONF_OFFSET,
25 offsetof(ngx_http_static_loc_conf_t, redirect_cache), 27 offsetof(ngx_http_static_loc_conf_t, redirect_cache),
26 NULL }, 28 NULL },
29
30 #endif
27 31
28 ngx_null_command 32 ngx_null_command
29 }; 33 };
30 34
31 35
85 89
86 if (rc != NGX_OK) { 90 if (rc != NGX_OK) {
87 return rc; 91 return rc;
88 } 92 }
89 93
94 #if (NGX_HTTP_CACHE)
95
90 /* 96 /*
91 * there is a valid cached open file, i.e by the index handler, 97 * there is a valid cached open file, i.e by the index handler,
92 * and it should be already registered in r->cleanup 98 * and it should be already registered in r->cleanup
93 */ 99 */
94 100
95 if (r->cache && !r->cache->expired) { 101 if (r->cache && !r->cache->expired) {
96 return ngx_http_send_cached(r); 102 return ngx_http_send_cached(r);
97 } 103 }
104
105 #endif
98 106
99 log = r->connection->log; 107 log = r->connection->log;
100 108
101 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 109 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
102 110
136 144
137 } else { 145 } else {
138 redirect_cleanup = NULL; 146 redirect_cleanup = NULL;
139 } 147 }
140 148
149 #if (NGX_HTTP_CACHE)
141 150
142 /* look up an open files cache */ 151 /* look up an open files cache */
143 152
144 if (clcf->open_files) { 153 if (clcf->open_files) {
145 file = ngx_http_cache_get(clcf->open_files, file_cleanup, 154 file = ngx_http_cache_get(clcf->open_files, file_cleanup,
190 199
191 } else { 200 } else {
192 redirect = NULL; 201 redirect = NULL;
193 } 202 }
194 203
204 #endif
195 205
196 /* open file */ 206 /* open file */
197 207
198 #if (WIN9X) 208 #if (WIN9X)
199 209
299 { 309 {
300 return NGX_HTTP_INTERNAL_SERVER_ERROR; 310 return NGX_HTTP_INTERNAL_SERVER_ERROR;
301 } 311 }
302 312
303 r->headers_out.location->value = location; 313 r->headers_out.location->value = location;
314
315 #if (NGX_HTTP_CACHE)
304 316
305 if (slcf->redirect_cache) { 317 if (slcf->redirect_cache) {
306 if (redirect) { 318 if (redirect) {
307 if (location.len == redirect->data.value.len 319 if (location.len == redirect->data.value.len
308 && ngx_memcmp(redirect->data.value.data, location.data, 320 && ngx_memcmp(redirect->data.value.data, location.data,
343 redirect_cleanup->valid = 0; 355 redirect_cleanup->valid = 0;
344 } 356 }
345 357
346 } 358 }
347 359
360 #endif
361
348 return NGX_HTTP_MOVED_PERMANENTLY; 362 return NGX_HTTP_MOVED_PERMANENTLY;
349 } 363 }
350 364
351 #if !(WIN32) /* the not regular files are probably Unix specific */ 365 #if !(WIN32) /* the not regular files are probably Unix specific */
352 366
362 return NGX_HTTP_NOT_FOUND; 376 return NGX_HTTP_NOT_FOUND;
363 } 377 }
364 378
365 #endif 379 #endif
366 380
381
382 #if (NGX_HTTP_CACHE)
367 383
368 if (clcf->open_files) { 384 if (clcf->open_files) {
369 385
370 #if (NGX_USE_HTTP_FILE_CACHE_UNIQ) 386 #if (NGX_USE_HTTP_FILE_CACHE_UNIQ)
371 387
414 } 430 }
415 431
416 return ngx_http_send_cached(r); 432 return ngx_http_send_cached(r);
417 } 433 }
418 434
435 #endif
419 436
420 ctx = log->data; 437 ctx = log->data;
421 ctx->action = "sending response to client"; 438 ctx->action = "sending response to client";
422 439
423 file_cleanup->data.file.fd = fd; 440 file_cleanup->data.file.fd = fd;