Skip to content

Commit e5037b5

Browse files
committed
Tests for header access in all cases
1 parent 1ac077d commit e5037b5

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

t/03-requestbody.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ c: 3
104104
[error]
105105
[warn]
106106

107+
107108
=== TEST 3: 100 Continue does not end requset
108109
--- http_config eval: $::HttpConfig
109110
--- config

t/12-case_insensitive_headers.t

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,43 @@ no_long_string();
2020
run_tests();
2121

2222
__DATA__
23-
=== TEST 1: Test headers can be accessed in all cases
23+
=== TEST 1: Test header normalisation
24+
--- http_config eval: $::HttpConfig
25+
--- config
26+
location = /a {
27+
content_by_lua '
28+
local http_headers = require "resty.http_headers"
29+
30+
local headers = http_headers.new()
31+
32+
headers.x_a_header = "a"
33+
headers["x-b-header"] = "b"
34+
headers["X-C-Header"] = "c"
35+
headers["X_d-HEAder"] = "d"
36+
37+
ngx.say(headers["X-A-Header"])
38+
ngx.say(headers.x_b_header)
39+
40+
for k,v in pairs(headers) do
41+
ngx.say(k, ": ", v)
42+
end
43+
';
44+
}
45+
--- request
46+
GET /a
47+
--- response_body
48+
a
49+
b
50+
x-b-header: b
51+
x-a-header: a
52+
X-d-HEAder: d
53+
X-C-Header: c
54+
--- no_error_log
55+
[error]
56+
[warn]
57+
58+
59+
=== TEST 2: Test headers can be accessed in all cases
2460
--- http_config eval: $::HttpConfig
2561
--- config
2662
location = /a {
@@ -58,7 +94,7 @@ bar
5894
[warn]
5995

6096

61-
=== TEST 2: Test request headers are normalised
97+
=== TEST 3: Test request headers are normalised
6298
--- http_config eval: $::HttpConfig
6399
--- config
64100
location = /a {
@@ -70,12 +106,12 @@ bar
70106
local res, err = httpc:request{
71107
path = "/b",
72108
headers = {
73-
user_agent = "test_user_agent",
109+
["uSeR-AgENT"] = "test_user_agent",
74110
},
75111
}
76112
77113
ngx.status = res.status
78-
ngx.say(res:read_body())
114+
ngx.print(res:read_body())
79115
80116
httpc:close()
81117
';

0 commit comments

Comments
 (0)