Mercurial > hg > nginx-quic
diff src/http/ngx_http_variables.c @ 515:417a087c9c4d release-0.1.32
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.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 19 May 2005 13:25:22 +0000 |
parents | 9b8c906f6e63 |
children | 12234c998d83 |
line wrap: on
line diff
--- 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_cor 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_reques 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;