You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openresty/patches/nginx-1.1.4-variable_header...

72 lines
1.5 KiB
Diff

--- nginx-1.1.4/src/http/ngx_http_variables.c 2011-05-30 20:36:17.000000000 +0800
+++ nginx-1.1.4-patched/src/http/ngx_http_variables.c 2011-11-08 21:39:28.509366052 +0800
@@ -648,7 +648,17 @@
a = (ngx_array_t *) ((char *) r + data);
- n = a->nelts;
+ h = a->elts;
+ n = 0;
+
+ for (i = 0; i < a->nelts; i++) {
+
+ if (h[i]->hash == 0) {
+ continue;
+ }
+
+ n++;
+ }
if (n == 0) {
v->not_found = 1;
@@ -659,9 +669,7 @@
v->no_cacheable = 0;
v->not_found = 0;
- h = a->elts;
-
- if (n == 1) {
+ if (n == 1 && a->nelts == 1) {
v->len = (*h)->value.len;
v->data = (*h)->value.data;
@@ -670,7 +678,12 @@
len = - (ssize_t) (sizeof("; ") - 1);
- for (i = 0; i < n; i++) {
+ for (i = 0; i < a->nelts; i++) {
+
+ if (h[i]->hash == 0) {
+ continue;
+ }
+
len += h[i]->value.len + sizeof("; ") - 1;
}
@@ -682,7 +695,12 @@
v->len = len;
v->data = p;
- for (i = 0; /* void */ ; i++) {
+ for (i = 0; i < n; i++) {
+
+ if (h[i]->hash == 0) {
+ continue;
+ }
+
p = ngx_copy(p, h[i]->value.data, h[i]->value.len);
if (i == n - 1) {
@@ -738,6 +756,10 @@
i = 0;
}
+ if (header[i].hash == 0) {
+ continue;
+ }
+
for (n = 0; n + prefix < var->len && n < header[i].key.len; n++) {
ch = header[i].key.data[n];