Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

bugfix: Cache-Control header modification might introduce empty value…

… headers when using with the standard ngx_headers module.
  • Loading branch information...
commit 6cd7ae83cb17c4dd91d6bf8ba2641b701c691c14 1 parent 55ad2f4
@agentzh agentzh authored
View
2  .gitignore
@@ -41,7 +41,7 @@ src/in.h
src/out.c
src/out.h
build[89]
-build10
+build1[01]
buildroot/
work/
all
View
8 src/ngx_http_headers_more_headers_out.c
@@ -315,7 +315,13 @@ ngx_http_set_builtin_multi_header(ngx_http_request_t *r,
}
ph[0]->value = *value;
- ph[0]->hash = hv->hash;
+
+ if (value->len == 0) {
+ ph[0]->hash = 0;
+
+ } else {
+ ph[0]->hash = hv->hash;
+ }
return NGX_OK;
}
View
22 t/bug.t
@@ -4,7 +4,7 @@ use Test::Nginx::Socket; # 'no_plan';
repeat_each(2);
-plan tests => 32 * repeat_each();
+plan tests => 35 * repeat_each();
no_diff;
@@ -225,3 +225,23 @@ Foo: b
foo
b
+
+
+=== TEST 13: set multi values to cache-control and override it with multiple values (to reproduce a bug)
+--- config
+ location /lua {
+ content_by_lua '
+ ngx.header.cache_control = { "private", "no-store", "foo", "bar", "baz" }
+ ngx.send_headers()
+ ngx.say("Cache-Control: ", ngx.var.sent_http_cache_control)
+ ';
+ more_clear_headers Cache-Control;
+ add_header Cache-Control "blah";
+ }
+--- request
+ GET /lua
+--- response_headers
+Cache-Control: blah
+--- response_body
+Cache-Control: blah
+
View
8 t/builtin.t
@@ -184,8 +184,8 @@ Content-Type: text/css
GET /len
--- response_headers
Content-Length: 2
---- response_body
-hello
+--- response_body chop
+he
@@ -200,8 +200,8 @@ hello
GET /len
--- response_headers
Content-Length: 4
---- response_body
-hello
+--- response_body chop
+hell
Please sign in to comment.
Something went wrong with that request. Please try again.