From e31e90b3e10ca2afafccae9a57910133d93b2d37 Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Thu, 19 May 2005 13:25:22 +0000 Subject: nginx-0.1.32-RELEASE import *) Bugfix: the arguments were omitted in the redirects, issued by the "rewrite" directive; the bug had appeared in 0.1.29. *) Feature: the "if" directive supports the captures in regular expressions. *) Feature: the "set" directive supports the variables and the captures of regular expressions. *) Feature: the "X-Accel-Redirect" response header line is supported in proxy and FastCGI mode. --- src/http/ngx_http_variables.c | 61 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'src/http/ngx_http_variables.c') diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c index 488efcc05..12ab5154b 100644 --- a/src/http/ngx_http_variables.c +++ b/src/http/ngx_http_variables.c @@ -14,6 +14,8 @@ static ngx_http_variable_value_t * ngx_http_variable_request(ngx_http_request_t *r, uintptr_t data); static ngx_http_variable_value_t * ngx_http_variable_header(ngx_http_request_t *r, uintptr_t data); +static ngx_http_variable_value_t * + ngx_http_variable_headers(ngx_http_request_t *r, uintptr_t data); static ngx_http_variable_value_t * ngx_http_variable_unknown_header(ngx_http_request_t *r, uintptr_t data); static ngx_http_variable_value_t * @@ -63,6 +65,9 @@ static ngx_http_variable_t ngx_http_core_variables[] = { offsetof(ngx_http_request_t, headers_in.x_forwarded_for), 0 }, #endif + { ngx_string("http_cookie"), ngx_http_variable_headers, + offsetof(ngx_http_request_t, headers_in.cookies), 0 }, + { ngx_string("content_length"), ngx_http_variable_header, offsetof(ngx_http_request_t, headers_in.content_length), 0 }, @@ -333,6 +338,62 @@ ngx_http_variable_header(ngx_http_request_t *r, uintptr_t data) } +static ngx_http_variable_value_t * +ngx_http_variable_headers(ngx_http_request_t *r, uintptr_t data) +{ + u_char *p; + ngx_uint_t i; + ngx_array_t *a; + ngx_table_elt_t **h; + ngx_http_variable_value_t *vv; + + a = (ngx_array_t *) ((char *) r + data); + + if (a->nelts == 0) { + return NGX_HTTP_VAR_NOT_FOUND; + } + + vv = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t)); + if (vv == NULL) { + return NULL; + } + + vv->value = 0; + + h = a->elts; + + if (a->nelts == 1) { + vv->text = (*h)->value; + return vv; + } + + vv->text.len = (size_t) - (ssize_t) (sizeof("; ") - 1); + + for (i = 0; i < a->nelts; i++) { + vv->text.len += h[i]->value.len + sizeof("; ") - 1; + } + + vv->text.data = ngx_palloc(r->pool, vv->text.len); + if (vv->text.data == NULL) { + return NULL; + } + + p = vv->text.data; + + for (i = 0; /* void */ ; i++) { + p = ngx_cpymem(p, h[i]->value.data, h[i]->value.len); + + if (i == a->nelts - 1) { + break; + } + + *p++ = ';'; *p++ = ' '; + } + + return vv; +} + + static ngx_http_variable_value_t * ngx_http_variable_unknown_header(ngx_http_request_t *r, uintptr_t data) { -- cgit