Mercurial > hg > nginx-vendor-0-8
diff src/http/ngx_http_request.c @ 456:ca8f7f6cab16 NGINX_0_7_40
nginx 0.7.40
*) Feature: the "location" directive supports captures in regular
expressions.
*) Feature: an "alias" directive with capture references may be used
inside a location given by a regular expression with captures.
*) Feature: the "server_name" directive supports captures in regular
expressions.
*) Workaround: the ngx_http_autoindex_module did not show the trailing
slash in directories on XFS filesystem; the issue had appeared in
0.7.15.
Thanks to Dmitry Kuzmenko.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 09 Mar 2009 00:00:00 +0300 |
parents | a8424ffa495c |
children | 2e2b57743e87 |
line wrap: on
line diff
--- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -1611,6 +1611,7 @@ static ngx_int_t ngx_http_find_virtual_server(ngx_http_request_t *r, u_char *host, size_t len) { u_char *server; + size_t ncaptures; ngx_uint_t hash; ngx_http_virtual_names_t *vn; ngx_http_core_loc_conf_t *clcf; @@ -1653,11 +1654,33 @@ ngx_http_find_virtual_server(ngx_http_re name.len = len; name.data = server; + ncaptures = 0; + sn = vn->regex; for (i = 0; i < vn->nregex; i++) { - n = ngx_regex_exec(sn[i].regex, &name, NULL, 0); + if (sn[i].captures && r->captures == NULL) { + + ncaptures = (NGX_HTTP_MAX_CAPTURES + 1) * 3 * sizeof(int); + + r->captures = ngx_palloc(r->pool, ncaptures); + if (r->captures == NULL) { + return NGX_ERROR; + } + + if (server == buf) { + server = ngx_pnalloc(r->pool, len); + if (server == NULL) { + return NGX_ERROR; + } + + ngx_memcpy(server, buf, len); + name.data = server; + } + } + + n = ngx_regex_exec(sn[i].regex, &name, r->captures, ncaptures); if (n == NGX_REGEX_NO_MATCHED) { continue; @@ -1675,6 +1698,9 @@ ngx_http_find_virtual_server(ngx_http_re cscf = sn[i].core_srv_conf; + r->ncaptures = ncaptures; + r->captures_data = server; + goto found; } }