aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_variables.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2011-03-16 15:32:31 +0000
committerIgor Sysoev <igor@sysoev.ru>2011-03-16 15:32:31 +0000
commit0519b43a772476a7537e02a34acb9b265e814815 (patch)
tree291b9eaa9e0a27313d60439b893c8d820f6aedeb /src/http/ngx_http_variables.c
parent32c73df97a205e59d3df9b6def7ca2beb36a4012 (diff)
downloadnginx-0519b43a772476a7537e02a34acb9b265e814815.tar.gz
nginx-0519b43a772476a7537e02a34acb9b265e814815.zip
allow regex as "map" parameter
Diffstat (limited to 'src/http/ngx_http_variables.c')
-rw-r--r--src/http/ngx_http_variables.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c
index 00d9d5eb4..3946e3867 100644
--- a/src/http/ngx_http_variables.c
+++ b/src/http/ngx_http_variables.c
@@ -1660,6 +1660,50 @@ ngx_http_variable_pid(ngx_http_request_t *r,
}
+void *
+ngx_http_map_find(ngx_http_request_t *r, ngx_http_map_t *map, ngx_uint_t key,
+ u_char *text, size_t len, ngx_str_t *match)
+{
+ void *p;
+
+ p = ngx_hash_find_combined(&map->hash, key, text, len);
+ if (p) {
+ return p;
+ }
+
+#if (NGX_PCRE)
+
+ if (len && map->nregex) {
+ ngx_int_t n;
+ ngx_uint_t i;
+ ngx_http_map_regex_t *reg;
+
+ reg = map->regex;
+
+ for (i = 0; i < map->nregex; i++) {
+
+ n = ngx_http_regex_exec(r, reg[i].regex, match);
+
+ if (n == NGX_OK) {
+ return reg[i].value;
+ }
+
+ if (n == NGX_DECLINED) {
+ continue;
+ }
+
+ /* NGX_ERROR */
+
+ return NULL;
+ }
+ }
+
+#endif
+
+ return NULL;
+}
+
+
#if (NGX_PCRE)
static ngx_int_t