chaoslawful/lua-nginx-module — Issue #65: t/016-resp-header.t TEST 32 dangling semicolon
Author: maage
Created: 2011-11-08 10:10:01+00:00
State: open

This test does not work okay,

=== TEST 32: set multi values to cache-control and override it with a single value
# Extra ; at the end of the line
--- config
location /lua {
content_by_lua '
ngx.header.cache_control = { "private", "no-store" }
ngx.header.cache_control = { "no-cache" }
ngx.say("Cache-Control: ", ngx.var.sent_http_cache_control)
ngx.say("Cache-Control: ", ngx.header.cache_control)
';
}
--- request
GET /lua
--- response_headers
Cache-Control: no-cache
--- response_body
Cache-Control: no-cache
Cache-Control: no-cache

Result is here:

t/016-resp-header.t .. 1/210
# Failed test 'TEST 32: set multi values to cache-control and override it with a single value - response_body - response is expected
# @@ -1,2 +1,2 @@
# -Cache-Control: no-cache
# +Cache-Control: no-cache;
# Cache-Control: no-cache
# '
# at /usr/local/share/perl5/Test/Nginx/Socket.pm line 675.

# Failed test 'TEST 32: set multi values to cache-control and override it with a single value - response_body - response is expected
# @@ -1,2 +1,2 @@
# -Cache-Control: no-cache
# +Cache-Control: no-cache;
# Cache-Control: no-cache
# '
# at /usr/local/share/perl5/Test/Nginx/Socket.pm line 675.

Because setting no-cache shortens array, but at ngx_http_set_builtin_multi_header array is not shortened, just extra elements len is set 0. At ngx_http_variable_headers len 0 is no checked.

I guess this is really bug at ngx_headers_more, but is now visible here.