aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_request.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2009-03-06 12:50:20 +0000
committerIgor Sysoev <igor@sysoev.ru>2009-03-06 12:50:20 +0000
commit7ac9f3605c3a4e687293fcec64a09f5233a82edf (patch)
tree8e121181ed6cc01e122240c5b309666af678047b /src/http/ngx_http_request.c
parent925baa0f955e0c66a0bb2360a4a453c8c7584e4c (diff)
downloadnginx-7ac9f3605c3a4e687293fcec64a09f5233a82edf.tar.gz
nginx-7ac9f3605c3a4e687293fcec64a09f5233a82edf.zip
captures support in server_name
Diffstat (limited to 'src/http/ngx_http_request.c')
-rw-r--r--src/http/ngx_http_request.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index faa8d7fa9..5a2a8f42c 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1653,11 +1653,33 @@ ngx_http_find_virtual_server(ngx_http_request_t *r, u_char *host, size_t len)
name.len = len;
name.data = server;
+ len = 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) {
+
+ len = (NGX_HTTP_MAX_CAPTURES + 1) * 3 * sizeof(int);
+
+ r->captures = ngx_palloc(r->pool, len);
+ 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, len);
if (n == NGX_REGEX_NO_MATCHED) {
continue;
@@ -1675,6 +1697,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 = len;
+ r->captures_data = server;
+
goto found;
}
}