summaryrefslogtreecommitdiff
path: root/src/http/ngx_http_request.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2009-03-09 08:54:41 +0000
committerJonathan Kolb <jon@b0g.us>2009-03-09 08:54:41 +0000
commit8b60224feb810a5f021dd1ba9bbd1ac69f8fbe67 (patch)
treedd698f856f465261939ac47da7ae59acf090c837 /src/http/ngx_http_request.c
parent474ee942eeff6170c5ff14b5004b3152fa60dd8a (diff)
downloadnginx-8b60224feb810a5f021dd1ba9bbd1ac69f8fbe67.tar.gz
Changes with nginx 0.7.40 09 Mar 2009v0.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.
Diffstat (limited to 'src/http/ngx_http_request.c')
-rw-r--r--src/http/ngx_http_request.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index faa8d7fa9..95a392a82 100644
--- 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_request_t *r, u_char *host, size_t len)
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_request_t *r, u_char *host, size_t len)
cscf = sn[i].core_srv_conf;
+ r->ncaptures = ncaptures;
+ r->captures_data = server;
+
goto found;
}
}