Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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 efd374014f15260d3687ca3a99e73a3b729d1bd4 1 parent ae29491
@agentzh agentzh authored
Showing with 13 additions and 7 deletions.
  1. +7 −1 src/ngx_http_lua_headers_out.c
  2. +6 −6 t/016-resp-header.t
View
8 src/ngx_http_lua_headers_out.c
@@ -280,7 +280,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
12 t/016-resp-header.t
@@ -7,7 +7,7 @@ use Test::Nginx::Socket;
#master_process_enabled(1);
#log_level('warn');
-repeat_each(2);
+#repeat_each(2);
plan tests => blocks() * repeat_each() * 3;
@@ -709,16 +709,16 @@ Foo: nil
location /lua {
content_by_lua '
ngx.header.cache_control = { "private", "no-store", "foo", "bar", "baz" }
- ngx.header.cache_control = { "no-cache", "blah", "foo" }
+ ngx.header.cache_control = {}
+ ngx.send_headers()
ngx.say("Cache-Control: ", ngx.var.sent_http_cache_control)
- ngx.say("Cache-Control: ", table.concat(ngx.header.cache_control, "; "))
';
+ add_header Cache-Control "blah";
}
--- request
GET /lua
--- response_headers
-Cache-Control: no-cache, blah, foo
+Cache-Control: blah
--- response_body
-Cache-Control: no-cache; blah; foo
-Cache-Control: no-cache; blah; foo
+Cache-Control: blah
Please sign in to comment.
Something went wrong with that request. Please try again.