Skip to content

Commit 8b9acca

Browse files
committed
test: multiple transfer-encoding headers
1 parent fe7341b commit 8b9acca

File tree

1 file changed

+62
-3
lines changed

1 file changed

+62
-3
lines changed

t/02-chunked.t

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
use Test::Nginx::Socket;
1+
use Test::Nginx::Socket 'no_plan';
22
use Cwd qw(cwd);
33

4-
plan tests => repeat_each() * (blocks() * 4);
5-
64
my $pwd = cwd();
75

86
$ENV{TEST_NGINX_RESOLVER} = '8.8.8.8';
@@ -163,3 +161,64 @@ GET /a
163161
--- no_error_log
164162
[error]
165163
[warn]
164+
165+
166+
=== TEST 4: Chunked. multiple-headers, mixed case
167+
--- http_config eval: $::HttpConfig
168+
--- config
169+
location = /a {
170+
content_by_lua_block {
171+
local http = require "resty.http"
172+
local httpc = http.new()
173+
httpc:connect("127.0.0.1", ngx.var.server_port)
174+
175+
local res, err = httpc:request{
176+
path = "/b"
177+
}
178+
179+
local chunks = {}
180+
local c = 1
181+
repeat
182+
local chunk, err = res.body_reader()
183+
if chunk then
184+
chunks[c] = chunk
185+
c = c + 1
186+
end
187+
until not chunk
188+
189+
local body = table.concat(chunks)
190+
191+
ngx.say(#body)
192+
ngx.say(#chunks)
193+
ngx.say(type(res.headers["Transfer-Encoding"]))
194+
httpc:close()
195+
}
196+
}
197+
location = /b {
198+
header_filter_by_lua_block {
199+
ngx.header["Transfer-Encoding"] = {"chUnked", "CHunked"}
200+
}
201+
content_by_lua_block {
202+
local len = 32768
203+
local t = {}
204+
for i=1,len do
205+
t[i] = 0
206+
end
207+
ngx.print(table.concat(t))
208+
local len = 32768
209+
local t = {}
210+
for i=1,len do
211+
t[i] = 0
212+
end
213+
ngx.print(table.concat(t))
214+
}
215+
}
216+
--- request
217+
GET /a
218+
--- response_body
219+
65536
220+
2
221+
table
222+
--- no_error_log
223+
[error]
224+
[warn]

0 commit comments

Comments
 (0)