Mercurial > hg > nginx-vendor-0-6
comparison src/http/ngx_http_core_module.c @ 144:e1c6ac408b68 NGINX_0_3_19
nginx 0.3.19
*) Feature: the "path" and "alias" directives support the variables.
*) Change: now the "valid_referers" directive again checks the URI part.
*) Bugfix: in SSI handling.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Wed, 28 Dec 2005 00:00:00 +0300 |
parents | 84910468f6de |
children | 36af50a5582d |
comparison
equal
deleted
inserted
replaced
143:c2fa0caa07f2 | 144:e1c6ac408b68 |
---|---|
982 | 982 |
983 u_char * | 983 u_char * |
984 ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *path, | 984 ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *path, |
985 size_t reserved) | 985 size_t reserved) |
986 { | 986 { |
987 u_char *last; | 987 u_char *last; |
988 size_t alias; | 988 size_t alias, len; |
989 ngx_http_core_loc_conf_t *clcf; | 989 ngx_http_script_code_pt code; |
990 ngx_http_script_engine_t e; | |
991 ngx_http_core_loc_conf_t *clcf; | |
992 ngx_http_script_len_code_pt lcode; | |
990 | 993 |
991 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | 994 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
992 | 995 |
993 alias = clcf->alias ? clcf->name.len : 0; | 996 alias = clcf->alias ? clcf->name.len : 0; |
994 | 997 |
995 path->len = clcf->root.len + r->uri.len - alias + 1 + reserved; | 998 if (clcf->root_lengths == NULL) { |
996 | 999 |
997 path->data = ngx_palloc(r->pool, path->len); | 1000 r->root_length = clcf->root.len; |
1001 | |
1002 path->len = clcf->root.len + r->uri.len - alias + 1 + reserved; | |
1003 | |
1004 path->data = ngx_palloc(r->pool, path->len); | |
1005 if (path->data == NULL) { | |
1006 return NULL; | |
1007 } | |
1008 | |
1009 last = ngx_copy(path->data, clcf->root.data, clcf->root.len); | |
1010 last = ngx_cpystrn(last, r->uri.data + alias, r->uri.len - alias + 1); | |
1011 | |
1012 return last; | |
1013 } | |
1014 | |
1015 ngx_memzero(&e, sizeof(ngx_http_script_engine_t)); | |
1016 | |
1017 e.ip = clcf->root_lengths->elts; | |
1018 e.request = r; | |
1019 e.flushed = 1; | |
1020 | |
1021 len = 0; | |
1022 | |
1023 while (*(uintptr_t *) e.ip) { | |
1024 lcode = *(ngx_http_script_len_code_pt *) e.ip; | |
1025 len += lcode(&e); | |
1026 } | |
1027 | |
1028 r->root_length = len; | |
1029 | |
1030 len += r->uri.len - alias + 1 + reserved; | |
1031 | |
1032 path->len = len; | |
1033 path->data = ngx_palloc(r->pool, len); | |
998 if (path->data == NULL) { | 1034 if (path->data == NULL) { |
999 return NULL; | 1035 return NULL; |
1000 } | 1036 } |
1001 | 1037 |
1002 last = ngx_copy(path->data, clcf->root.data, clcf->root.len); | 1038 e.ip = clcf->root_values->elts; |
1003 last = ngx_cpystrn(last, r->uri.data + alias, r->uri.len - alias + 1); | 1039 e.pos = path->data; |
1040 | |
1041 while (*(uintptr_t *) e.ip) { | |
1042 code = *(ngx_http_script_code_pt *) e.ip; | |
1043 code((ngx_http_script_engine_t *) &e); | |
1044 } | |
1045 | |
1046 last = ngx_cpystrn(e.pos, r->uri.data + alias, r->uri.len - alias + 1); | |
1004 | 1047 |
1005 return last; | 1048 return last; |
1006 } | 1049 } |
1007 | 1050 |
1008 | 1051 |
1955 if (conf->post_action.data == NULL) { | 1998 if (conf->post_action.data == NULL) { |
1956 conf->post_action = prev->post_action; | 1999 conf->post_action = prev->post_action; |
1957 } | 2000 } |
1958 | 2001 |
1959 ngx_conf_merge_unsigned_value(conf->types_hash_max_size, | 2002 ngx_conf_merge_unsigned_value(conf->types_hash_max_size, |
1960 prev->types_hash_max_size, 512); | 2003 prev->types_hash_max_size, 1024); |
1961 | 2004 |
1962 ngx_conf_merge_unsigned_value(conf->types_hash_bucket_size, | 2005 ngx_conf_merge_unsigned_value(conf->types_hash_bucket_size, |
1963 prev->types_hash_bucket_size, | 2006 prev->types_hash_bucket_size, |
1964 ngx_cacheline_size); | 2007 ngx_cacheline_size); |
1965 | 2008 |
1975 | 2018 |
1976 types_hash.hash = &prev->types_hash; | 2019 types_hash.hash = &prev->types_hash; |
1977 types_hash.key = ngx_hash_key_lc; | 2020 types_hash.key = ngx_hash_key_lc; |
1978 types_hash.max_size = conf->types_hash_max_size; | 2021 types_hash.max_size = conf->types_hash_max_size; |
1979 types_hash.bucket_size = conf->types_hash_bucket_size; | 2022 types_hash.bucket_size = conf->types_hash_bucket_size; |
1980 types_hash.name = "mime_types"; | 2023 types_hash.name = "types_hash"; |
1981 types_hash.pool = cf->pool; | 2024 types_hash.pool = cf->pool; |
1982 types_hash.temp_pool = NULL; | 2025 types_hash.temp_pool = NULL; |
1983 | 2026 |
1984 if (ngx_hash_init(&types_hash, prev->types->elts, prev->types->nelts) | 2027 if (ngx_hash_init(&types_hash, prev->types->elts, prev->types->nelts) |
1985 != NGX_OK) | 2028 != NGX_OK) |
2017 | 2060 |
2018 types_hash.hash = &conf->types_hash; | 2061 types_hash.hash = &conf->types_hash; |
2019 types_hash.key = ngx_hash_key_lc; | 2062 types_hash.key = ngx_hash_key_lc; |
2020 types_hash.max_size = conf->types_hash_max_size; | 2063 types_hash.max_size = conf->types_hash_max_size; |
2021 types_hash.bucket_size = conf->types_hash_bucket_size; | 2064 types_hash.bucket_size = conf->types_hash_bucket_size; |
2022 types_hash.name = "mime_types"; | 2065 types_hash.name = "mime_types_hash"; |
2023 types_hash.pool = cf->pool; | 2066 types_hash.pool = cf->pool; |
2024 types_hash.temp_pool = NULL; | 2067 types_hash.temp_pool = NULL; |
2025 | 2068 |
2026 if (ngx_hash_init(&types_hash, conf->types->elts, conf->types->nelts) | 2069 if (ngx_hash_init(&types_hash, conf->types->elts, conf->types->nelts) |
2027 != NGX_OK) | 2070 != NGX_OK) |
2338 static char * | 2381 static char * |
2339 ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 2382 ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
2340 { | 2383 { |
2341 ngx_http_core_loc_conf_t *lcf = conf; | 2384 ngx_http_core_loc_conf_t *lcf = conf; |
2342 | 2385 |
2343 ngx_uint_t alias; | 2386 ngx_str_t *value; |
2344 ngx_str_t *value; | 2387 ngx_uint_t alias, n; |
2388 ngx_http_script_compile_t sc; | |
2345 | 2389 |
2346 alias = (cmd->name.len == sizeof("alias") - 1) ? 1 : 0; | 2390 alias = (cmd->name.len == sizeof("alias") - 1) ? 1 : 0; |
2347 | 2391 |
2348 if (lcf->root.data) { | 2392 if (lcf->root.data) { |
2349 | 2393 |
2370 | 2414 |
2371 if (!alias && lcf->root.data[lcf->root.len - 1] == '/') { | 2415 if (!alias && lcf->root.data[lcf->root.len - 1] == '/') { |
2372 lcf->root.len--; | 2416 lcf->root.len--; |
2373 } | 2417 } |
2374 | 2418 |
2419 n = ngx_http_script_variables_count(&value[1]); | |
2420 | |
2421 if (n == 0) { | |
2422 return NGX_CONF_OK; | |
2423 } | |
2424 | |
2425 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | |
2426 | |
2427 sc.cf = cf; | |
2428 sc.source = &value[1]; | |
2429 sc.lengths = &lcf->root_lengths; | |
2430 sc.values = &lcf->root_values; | |
2431 sc.variables = n; | |
2432 sc.complete_lengths = 1; | |
2433 sc.complete_values = 1; | |
2434 | |
2435 if (ngx_http_script_compile(&sc) != NGX_OK) { | |
2436 return NGX_CONF_ERROR; | |
2437 } | |
2438 | |
2375 return NGX_CONF_OK; | 2439 return NGX_CONF_OK; |
2376 } | 2440 } |
2377 | 2441 |
2378 | 2442 |
2379 static char * | 2443 static char * |