Mercurial > hg > nginx
comparison src/http/modules/ngx_http_index_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 |
---|---|
44 ngx_http_index_set_index, | 44 ngx_http_index_set_index, |
45 NGX_HTTP_LOC_CONF_OFFSET, | 45 NGX_HTTP_LOC_CONF_OFFSET, |
46 0, | 46 0, |
47 NULL }, | 47 NULL }, |
48 | 48 |
49 #if (NGX_HTTP_CACHE) | |
50 | |
49 { ngx_string("index_cache"), | 51 { ngx_string("index_cache"), |
50 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE3, | 52 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE3, |
51 ngx_http_set_cache_slot, | 53 ngx_http_set_cache_slot, |
52 NGX_HTTP_LOC_CONF_OFFSET, | 54 NGX_HTTP_LOC_CONF_OFFSET, |
53 offsetof(ngx_http_index_loc_conf_t, index_cache), | 55 offsetof(ngx_http_index_loc_conf_t, index_cache), |
54 NULL }, | 56 NULL }, |
57 | |
58 #endif | |
55 | 59 |
56 ngx_null_command | 60 ngx_null_command |
57 }; | 61 }; |
58 | 62 |
59 | 63 |
123 if (ctx == NULL) { | 127 if (ctx == NULL) { |
124 ngx_http_create_ctx(r, ctx, ngx_http_index_module, | 128 ngx_http_create_ctx(r, ctx, ngx_http_index_module, |
125 sizeof(ngx_http_index_ctx_t), | 129 sizeof(ngx_http_index_ctx_t), |
126 NGX_HTTP_INTERNAL_SERVER_ERROR); | 130 NGX_HTTP_INTERNAL_SERVER_ERROR); |
127 | 131 |
132 #if (NGX_HTTP_CACHE) | |
133 | |
128 if (ilcf->index_cache) { | 134 if (ilcf->index_cache) { |
129 ctx->cache = ngx_http_cache_get(ilcf->index_cache, NULL, | 135 ctx->cache = ngx_http_cache_get(ilcf->index_cache, NULL, |
130 &r->uri, &crc); | 136 &r->uri, &crc); |
131 | 137 |
132 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, | 138 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, |
147 ctx->redirect.len + 1); | 153 ctx->redirect.len + 1); |
148 ngx_http_cache_unlock(ilcf->index_cache, ctx->cache, log); | 154 ngx_http_cache_unlock(ilcf->index_cache, ctx->cache, log); |
149 | 155 |
150 return ngx_http_internal_redirect(r, &ctx->redirect, NULL); | 156 return ngx_http_internal_redirect(r, &ctx->redirect, NULL); |
151 } | 157 } |
152 | 158 } |
153 } else { | 159 |
154 ctx->cache = NULL; | 160 #endif |
155 } | |
156 | 161 |
157 len = clcf->doc_root.len + r->uri.len + ilcf->max_index_len; | 162 len = clcf->doc_root.len + r->uri.len + ilcf->max_index_len; |
158 if (!(ctx->path.data = ngx_palloc(r->pool, len))) { | 163 if (!(ctx->path.data = ngx_palloc(r->pool, len))) { |
159 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 164 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
160 } | 165 } |
234 + index[ctx->index].len; | 239 + index[ctx->index].len; |
235 } | 240 } |
236 | 241 |
237 /**/ | 242 /**/ |
238 | 243 |
244 | |
245 #if (NGX_HTTP_CACHE) | |
239 | 246 |
240 if (ilcf->index_cache) { | 247 if (ilcf->index_cache) { |
241 | 248 |
242 if (ctx->cache) { | 249 if (ctx->cache) { |
243 if (ctx->redirect.len == ctx->cache->data.value.len | 250 if (ctx->redirect.len == ctx->cache->data.value.len |
269 ctx->cache->memory = 1; | 276 ctx->cache->memory = 1; |
270 ngx_http_cache_unlock(ilcf->index_cache, ctx->cache, log); | 277 ngx_http_cache_unlock(ilcf->index_cache, ctx->cache, log); |
271 } | 278 } |
272 } | 279 } |
273 | 280 |
281 #endif | |
282 | |
274 return ngx_http_internal_redirect(r, &ctx->redirect, NULL); | 283 return ngx_http_internal_redirect(r, &ctx->redirect, NULL); |
275 } | 284 } |
276 | 285 |
277 return NGX_DECLINED; | 286 return NGX_DECLINED; |
278 } | 287 } |