aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_variables.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/ngx_http_variables.c')
-rw-r--r--src/http/ngx_http_variables.c41
1 files changed, 17 insertions, 24 deletions
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c
index b0f06ac7c..69462f10c 100644
--- a/src/http/ngx_http_variables.c
+++ b/src/http/ngx_http_variables.c
@@ -183,7 +183,7 @@ static ngx_http_variable_t ngx_http_core_variables[] = {
#endif
{ ngx_string("http_cookie"), NULL, ngx_http_variable_cookies,
- offsetof(ngx_http_request_t, headers_in.cookies), 0, 0 },
+ offsetof(ngx_http_request_t, headers_in.cookie), 0, 0 },
{ ngx_string("content_length"), NULL, ngx_http_variable_content_length,
0, 0, 0 },
@@ -846,26 +846,21 @@ static ngx_int_t
ngx_http_variable_headers_internal(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data, u_char sep)
{
- size_t len;
- u_char *p, *end;
- ngx_uint_t i, n;
- ngx_array_t *a;
- ngx_table_elt_t **h;
-
- a = (ngx_array_t *) ((char *) r + data);
+ size_t len;
+ u_char *p;
+ ngx_table_elt_t *h, *th;
- n = a->nelts;
- h = a->elts;
+ h = *(ngx_table_elt_t **) ((char *) r + data);
len = 0;
- for (i = 0; i < n; i++) {
+ for (th = h; th; th = th->next) {
- if (h[i]->hash == 0) {
+ if (th->hash == 0) {
continue;
}
- len += h[i]->value.len + 2;
+ len += th->value.len + 2;
}
if (len == 0) {
@@ -879,9 +874,9 @@ ngx_http_variable_headers_internal(ngx_http_request_t *r,
v->no_cacheable = 0;
v->not_found = 0;
- if (n == 1) {
- v->len = (*h)->value.len;
- v->data = (*h)->value.data;
+ if (h->next == NULL) {
+ v->len = h->value.len;
+ v->data = h->value.data;
return NGX_OK;
}
@@ -894,17 +889,15 @@ ngx_http_variable_headers_internal(ngx_http_request_t *r,
v->len = len;
v->data = p;
- end = p + len;
-
- for (i = 0; /* void */ ; i++) {
+ for (th = h; th; th = th->next) {
- if (h[i]->hash == 0) {
+ if (th->hash == 0) {
continue;
}
- p = ngx_copy(p, h[i]->value.data, h[i]->value.len);
+ p = ngx_copy(p, th->value.data, th->value.len);
- if (p == end) {
+ if (th->next == NULL) {
break;
}
@@ -1102,8 +1095,8 @@ ngx_http_variable_cookie(ngx_http_request_t *r, ngx_http_variable_value_t *v,
s.len = name->len - (sizeof("cookie_") - 1);
s.data = name->data + sizeof("cookie_") - 1;
- if (ngx_http_parse_multi_header_lines(&r->headers_in.cookies, &s, &cookie)
- == NGX_DECLINED)
+ if (ngx_http_parse_multi_header_lines(r, r->headers_in.cookie, &s, &cookie)
+ == NULL)
{
v->not_found = 1;
return NGX_OK;