comparison src/http/modules/ngx_http_index_handler.c @ 290:87e73f067470

nginx-0.0.2-2004-03-16-10:10:12 import
author Igor Sysoev <igor@sysoev.ru>
date Tue, 16 Mar 2004 07:10:12 +0000
parents f81d075ad172
children a472bfb778b3
comparison
equal deleted inserted replaced
289:0750faf8d7e3 290:87e73f067470
10 ngx_http_cache_hash_t *index_cache; 10 ngx_http_cache_hash_t *index_cache;
11 } ngx_http_index_loc_conf_t; 11 } ngx_http_index_loc_conf_t;
12 12
13 13
14 typedef struct { 14 typedef struct {
15 ngx_int_t index; 15 ngx_uint_t index;
16 char *last; 16 u_char *last;
17 ngx_str_t path; 17 ngx_str_t path;
18 ngx_str_t redirect; 18 ngx_str_t redirect;
19 ngx_http_cache_t *cache; 19 ngx_http_cache_t *cache;
20 unsigned tested:1; 20 unsigned tested:1;
21 } ngx_http_index_ctx_t; 21 } ngx_http_index_ctx_t;
95 * that path contains the usual file in place of the directory. 95 * that path contains the usual file in place of the directory.
96 */ 96 */
97 97
98 int ngx_http_index_handler(ngx_http_request_t *r) 98 int ngx_http_index_handler(ngx_http_request_t *r)
99 { 99 {
100 char *name; 100 u_char *name;
101 size_t len; 101 size_t len;
102 ngx_fd_t fd; 102 ngx_fd_t fd;
103 ngx_int_t rc; 103 ngx_int_t rc;
104 ngx_str_t *index; 104 ngx_str_t *index;
105 ngx_err_t err; 105 ngx_err_t err;
159 } 159 }
160 } 160 }
161 161
162 #endif 162 #endif
163 163
164 len = clcf->doc_root.len + r->uri.len + ilcf->max_index_len; 164 len = clcf->root.len + r->uri.len + ilcf->max_index_len;
165 if (!(ctx->path.data = ngx_palloc(r->pool, len))) { 165 if (!(ctx->path.data = ngx_palloc(r->pool, len))) {
166 return NGX_HTTP_INTERNAL_SERVER_ERROR; 166 return NGX_HTTP_INTERNAL_SERVER_ERROR;
167 } 167 }
168 168
169 ctx->redirect.data = ngx_cpymem(ctx->path.data, clcf->doc_root.data, 169 ctx->redirect.data = ngx_cpymem(ctx->path.data, clcf->root.data,
170 clcf->doc_root.len); 170 clcf->root.len);
171 ctx->last = ngx_cpystrn(ctx->redirect.data, r->uri.data, 171 ctx->last = ngx_cpystrn(ctx->redirect.data, r->uri.data,
172 r->uri.len + 1); 172 r->uri.len + 1);
173 ctx->path.len = ctx->last - ctx->path.data; 173 ctx->path.len = ctx->last - ctx->path.data;
174 } 174 }
175 175
235 ctx->redirect.len = index[ctx->index].len; 235 ctx->redirect.len = index[ctx->index].len;
236 ctx->redirect.data = index[ctx->index].data; 236 ctx->redirect.data = index[ctx->index].data;
237 237
238 } else { 238 } else {
239 ctx->redirect.len = r->uri.len + index[ctx->index].len; 239 ctx->redirect.len = r->uri.len + index[ctx->index].len;
240 r->file.name.len = clcf->doc_root.len + r->uri.len 240 r->file.name.len = clcf->root.len + r->uri.len
241 + index[ctx->index].len; 241 + index[ctx->index].len;
242 } 242 }
243 243
244 /**/ 244 /**/
245 245
385 void *parent, void *child) 385 void *parent, void *child)
386 { 386 {
387 ngx_http_index_loc_conf_t *prev = parent; 387 ngx_http_index_loc_conf_t *prev = parent;
388 ngx_http_index_loc_conf_t *conf = child; 388 ngx_http_index_loc_conf_t *conf = child;
389 389
390 int i; 390 ngx_uint_t i;
391 ngx_str_t *index, *prev_index; 391 ngx_str_t *index, *prev_index;
392 392
393 if (conf->max_index_len == 0) { 393 if (conf->max_index_len == 0) {
394 if (prev->max_index_len != 0) { 394 if (prev->max_index_len != 0) {
395 ngx_memcpy(conf, prev, sizeof(ngx_http_index_loc_conf_t)); 395 ngx_memcpy(conf, prev, sizeof(ngx_http_index_loc_conf_t));
432 static char *ngx_http_index_set_index(ngx_conf_t *cf, ngx_command_t *cmd, 432 static char *ngx_http_index_set_index(ngx_conf_t *cf, ngx_command_t *cmd,
433 void *conf) 433 void *conf)
434 { 434 {
435 ngx_http_index_loc_conf_t *ilcf = conf; 435 ngx_http_index_loc_conf_t *ilcf = conf;
436 436
437 int i; 437 ngx_uint_t i;
438 ngx_str_t *index, *value; 438 ngx_str_t *index, *value;
439 439
440 value = cf->args->elts; 440 value = cf->args->elts;
441 441
442 if (value[1].data[0] == '/' && ilcf->indices.nelts == 0) { 442 if (value[1].data[0] == '/' && ilcf->indices.nelts == 0) {