Mercurial > hg > nginx-mail
diff src/http/ngx_http_core_module.c @ 308:94e16de3c33f NGINX_0_5_24
nginx 0.5.24
*) Security: the "ssl_verify_client" directive did not work if request
was made using HTTP/0.9.
*) Bugfix: a part of response body might be passed uncompressed if gzip
was used; bug appeared in 0.5.23.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Wed, 06 Jun 2007 00:00:00 +0400 |
parents | 9b7db0df50f0 |
children | 95d92ec39071 |
line wrap: on
line diff
--- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -29,7 +29,7 @@ typedef struct { static ngx_int_t ngx_http_core_find_location(ngx_http_request_t *r, - ngx_array_t *locations, size_t len); + ngx_array_t *locations, ngx_uint_t regex_start, size_t len); static ngx_int_t ngx_http_core_preconfiguration(ngx_conf_t *cf); static void *ngx_http_core_create_main_conf(ngx_conf_t *cf); @@ -629,7 +629,7 @@ ngx_http_core_find_config_phase(ngx_http cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); - rc = ngx_http_core_find_location(r, &cscf->locations, 0); + rc = ngx_http_core_find_location(r, &cscf->locations, cscf->regex_start, 0); if (rc == NGX_HTTP_INTERNAL_SERVER_ERROR) { ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); @@ -930,7 +930,7 @@ ngx_http_update_location_config(ngx_http static ngx_int_t ngx_http_core_find_location(ngx_http_request_t *r, - ngx_array_t *locations, size_t len) + ngx_array_t *locations, ngx_uint_t regex_start, size_t len) { ngx_int_t n, rc; ngx_uint_t i, found, noregex; @@ -1008,8 +1008,9 @@ ngx_http_core_find_location(ngx_http_req if (found) { clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); - if (clcf->locations.nelts) { - rc = ngx_http_core_find_location(r, &clcf->locations, len); + if (clcf->locations) { + rc = ngx_http_core_find_location(r, clcf->locations, + clcf->regex_start, len); if (rc != NGX_OK) { return rc; @@ -1025,11 +1026,7 @@ ngx_http_core_find_location(ngx_http_req /* regex matches */ - for (/* void */; i < locations->nelts; i++) { - - if (!clcfp[i]->regex) { - continue; - } + for (i = regex_start; i < locations->nelts; i++) { if (clcfp[i]->noname) { break; @@ -1553,14 +1550,15 @@ ngx_http_cleanup_add(ngx_http_request_t static char * ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy) { - char *rv; - void *mconf; - ngx_uint_t m; - ngx_conf_t pcf; - ngx_http_module_t *module; - ngx_http_conf_ctx_t *ctx, *http_ctx; - ngx_http_core_srv_conf_t *cscf, **cscfp; - ngx_http_core_main_conf_t *cmcf; + char *rv; + void *mconf; + ngx_uint_t i, m; + ngx_conf_t pcf; + ngx_http_module_t *module; + ngx_http_conf_ctx_t *ctx, *http_ctx; + ngx_http_core_srv_conf_t *cscf, **cscfp; + ngx_http_core_loc_conf_t **clcfp; + ngx_http_core_main_conf_t *cmcf; ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)); if (ctx == NULL) { @@ -1644,6 +1642,16 @@ ngx_http_core_server(ngx_conf_t *cf, ngx ngx_sort(cscf->locations.elts, (size_t) cscf->locations.nelts, sizeof(ngx_http_core_loc_conf_t *), ngx_http_core_cmp_locations); + cscf->regex_start = cscf->locations.nelts; + clcfp = cscf->locations.elts; + + for (i = 0; i < cscf->locations.nelts; i++) { + if (clcfp[i]->regex) { + cscf->regex_start = i; + break; + } + } + return rv; } @@ -1652,7 +1660,7 @@ static char * ngx_http_core_location(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy) { char *rv; - ngx_int_t m; + ngx_uint_t i, m; ngx_str_t *value; ngx_conf_t save; ngx_http_module_t *module; @@ -1785,15 +1793,15 @@ ngx_http_core_location(ngx_conf_t *cf, n return NGX_CONF_ERROR; } - if (pclcf->locations.elts == NULL) { - if (ngx_array_init(&pclcf->locations, cf->pool, 4, sizeof(void *)) - != NGX_OK) - { + if (pclcf->locations == NULL) { + pclcf->locations = ngx_array_create(cf->pool, 2, sizeof(void *)); + + if (pclcf->locations == NULL) { return NGX_CONF_ERROR; } } - clcfp = ngx_array_push(&pclcf->locations); + clcfp = ngx_array_push(pclcf->locations); if (clcfp == NULL) { return NGX_CONF_ERROR; } @@ -1813,9 +1821,23 @@ ngx_http_core_location(ngx_conf_t *cf, n return rv; } - ngx_sort(clcf->locations.elts, (size_t) clcf->locations.nelts, + if (clcf->locations == NULL) { + return rv; + } + + ngx_sort(clcf->locations->elts, (size_t) clcf->locations->nelts, sizeof(ngx_http_core_loc_conf_t *), ngx_http_core_cmp_locations); + clcf->regex_start = clcf->locations->nelts; + clcfp = clcf->locations->elts; + + for (i = 0; i < clcf->locations->nelts; i++) { + if (clcfp[i]->regex) { + clcf->regex_start = i; + break; + } + } + return rv; } @@ -2674,6 +2696,18 @@ ngx_http_core_root(ngx_conf_t *cf, ngx_c return NGX_CONF_ERROR; } +#if (NGX_PCRE) + + if (lcf->regex && alias) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "the \"alias\" directive may not be used " + "inside location given by regular expression"); + + return NGX_CONF_ERROR; + } + +#endif + value = cf->args->elts; if (ngx_strstr(value[1].data, "$document_root") @@ -2825,15 +2859,14 @@ ngx_http_core_limit_except(ngx_conf_t *c lcf->name = clcf->name; lcf->noname = 1; - if (clcf->locations.elts == NULL) { - if (ngx_array_init(&clcf->locations, cf->pool, 4, sizeof(void *)) - == NGX_ERROR) - { + if (clcf->locations == NULL) { + clcf->locations = ngx_array_create(cf->pool, 2, sizeof(void *)); + if (clcf->locations == NULL) { return NGX_CONF_ERROR; } } - clcfp = ngx_array_push(&clcf->locations); + clcfp = ngx_array_push(clcf->locations); if (clcfp == NULL) { return NGX_CONF_ERROR; }