Skip to content

Commit debf25d

Browse files
authored
test: add more tests for getting all resp headers (#39)
1 parent b8ed486 commit debf25d

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

t/http_header.t

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,58 @@ get response header x-foo bar,
200200
get response header content-type text/plain,
201201
get response header content-length 4,
202202
get response header connection close,
203+
204+
205+
206+
=== TEST 12: response header get all, repeated header
207+
--- config
208+
location /t {
209+
return 200 "body";
210+
header_filter_by_lua_block {
211+
local resp = require("ngx.resp")
212+
ngx.header["Content-Type"] = "text/html"
213+
ngx.header["X-WASM"] = "true"
214+
resp.add_header("X-WASM", "false")
215+
216+
local wasm = require("resty.proxy-wasm")
217+
local plugin = assert(wasm.load("plugin", "t/testdata/http_header/main.go.wasm"))
218+
local ctx = assert(wasm.on_configure(plugin, 'resp_hdr_get_all'))
219+
assert(wasm.on_http_response_headers(ctx))
220+
}
221+
}
222+
--- grep_error_log eval
223+
qr/get response header \S+ \S+/
224+
--- grep_error_log_out
225+
get response header x-wasm true,
226+
get response header x-wasm false,
227+
get response header content-type text/html,
228+
get response header content-length 4,
229+
get response header connection close,
230+
231+
232+
233+
=== TEST 13: response header get all, keepalive
234+
--- config
235+
location /up {
236+
return 200;
237+
header_filter_by_lua_block {
238+
local wasm = require("resty.proxy-wasm")
239+
local plugin = assert(wasm.load("plugin", "t/testdata/http_header/main.go.wasm"))
240+
local ctx = assert(wasm.on_configure(plugin, 'resp_hdr_get_all'))
241+
assert(wasm.on_http_response_headers(ctx))
242+
}
243+
}
244+
location /t {
245+
content_by_lua_block {
246+
local http = require("resty.http")
247+
local uri = "http://127.0.0.1:" .. ngx.var.server_port .. "/up"
248+
local httpc = http.new()
249+
assert(httpc:request_uri(uri))
250+
}
251+
}
252+
--- grep_error_log eval
253+
qr/get response header \S+ \S+/
254+
--- grep_error_log_out
255+
get response header content-type text/plain,
256+
get response header content-length 0,
257+
get response header connection keep-alive,

0 commit comments

Comments
 (0)