Skip to content

Commit f2bc913

Browse files
committed
test: header and mt uniqueness
1 parent a1d326d commit f2bc913

File tree

1 file changed

+39
-8
lines changed

1 file changed

+39
-8
lines changed

t/12-case_insensitive_headers.t

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ my $pwd = cwd();
66
$ENV{TEST_COVERAGE} ||= 0;
77

88
our $HttpConfig = qq{
9-
lua_package_path "$pwd/lib/?.lua;;";
9+
lua_package_path "$pwd/lib/?.lua;;";
1010
11-
init_by_lua_block {
12-
if $ENV{TEST_COVERAGE} == 1 then
13-
jit.off()
14-
require("luacov.runner").init()
15-
end
16-
}
11+
init_by_lua_block {
12+
if $ENV{TEST_COVERAGE} == 1 then
13+
jit.off()
14+
require("luacov.runner").init()
15+
end
16+
}
1717
18-
underscores_in_headers On;
18+
underscores_in_headers On;
1919
};
2020

2121
no_long_string();
@@ -46,6 +46,7 @@ location = /a {
4646
4747
assert(headers["SSL-CLIENT-CERTIFICATE"] ~= headers["SSL_CLIENT_CERTIFICATE"],
4848
"underscores are separate to hyphens")
49+
4950
}
5051
}
5152
--- request
@@ -149,3 +150,33 @@ GET /a
149150
x-a-header: b
150151
--- no_error_log
151152
[error]
153+
154+
155+
=== TEST 5: Prove header tables are always unique
156+
--- http_config eval: $::HttpConfig
157+
--- config
158+
location = /a {
159+
content_by_lua_block {
160+
local headers = require("resty.http_headers").new()
161+
162+
headers["content-length"] = "a"
163+
headers["TRANSFER-ENCODING"] = "b"
164+
headers["SSL_CLIENT_CERTIFICATE"] = "foo"
165+
166+
local headers2 = require("resty.http_headers").new()
167+
168+
assert(headers2 ~= headers,
169+
"headers should be unique")
170+
171+
assert(not next(headers2),
172+
"headers2 should be empty")
173+
174+
assert(not next(getmetatable(headers2).normalised),
175+
"headers normalised data should be empty")
176+
}
177+
}
178+
--- request
179+
GET /a
180+
--- response_body
181+
--- no_error_log
182+
[error]

0 commit comments

Comments
 (0)