diff options
author | Igor Sysoev <igor@sysoev.ru> | 2005-05-19 17:25:22 +0400 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2005-05-19 17:25:22 +0400 |
commit | e31e90b3e10ca2afafccae9a57910133d93b2d37 (patch) | |
tree | 7177a8f48a555733b170bfcad4e9e7072ea8c027 /src/http/ngx_http_variables.c | |
parent | b1a641cafa2ef042035155f68e5f571303853dfc (diff) |
nginx-0.1.32-RELEASE importrelease-0.1.32
*) 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.
Diffstat (limited to 'src/http/ngx_http_variables.c')
-rw-r--r-- | src/http/ngx_http_variables.c | 61 |
1 files changed, 61 insertions, 0 deletions
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 @@ -15,6 +15,8 @@ static ngx_http_variable_value_t * 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 * ngx_http_variable_host(ngx_http_request_t *r, uintptr_t data); @@ -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 }, @@ -334,6 +339,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) { ngx_str_t *var = (ngx_str_t *) data; |