added some tests for ngx.decode_args().
This commit is contained in:
Родитель
ecd83e9a1b
Коммит
6a61f43845
|
@ -1002,3 +1002,91 @@ CORE::join("", @k);
|
|||
--- response_body
|
||||
HTTP/1.0 a=3&b=5&b=6
|
||||
|
||||
|
||||
|
||||
=== TEST 42: ngx.decode_args (sanity)
|
||||
--- config
|
||||
location /lua {
|
||||
content_by_lua '
|
||||
local args = "a=bar&b=foo"
|
||||
args = ngx.decode_args(args)
|
||||
ngx.say("a = ", args.a)
|
||||
ngx.say("b = ", args.b)
|
||||
';
|
||||
}
|
||||
--- request
|
||||
GET /lua
|
||||
--- response_body
|
||||
a = bar
|
||||
b = foo
|
||||
|
||||
|
||||
|
||||
=== TEST 43: ngx.decode_args (multi-value)
|
||||
--- config
|
||||
location /lua {
|
||||
content_by_lua '
|
||||
local args = "a=bar&b=foo&a=baz"
|
||||
args = ngx.decode_args(args)
|
||||
ngx.say("a = ", table.concat(args.a, ", "))
|
||||
ngx.say("b = ", args.b)
|
||||
';
|
||||
}
|
||||
--- request
|
||||
GET /lua
|
||||
--- response_body
|
||||
a = bar, baz
|
||||
b = foo
|
||||
|
||||
|
||||
|
||||
=== TEST 44: ngx.decode_args (empty string)
|
||||
--- config
|
||||
location /lua {
|
||||
content_by_lua '
|
||||
local args = ""
|
||||
args = ngx.decode_args(args)
|
||||
ngx.say("n = ", #args)
|
||||
';
|
||||
}
|
||||
--- request
|
||||
GET /lua
|
||||
--- response_body
|
||||
n = 0
|
||||
|
||||
|
||||
|
||||
=== TEST 45: ngx.decode_args (boolean args)
|
||||
--- config
|
||||
location /lua {
|
||||
content_by_lua '
|
||||
local args = "a&b"
|
||||
args = ngx.decode_args(args)
|
||||
ngx.say("a = ", args.a)
|
||||
ngx.say("b = ", args.b)
|
||||
';
|
||||
}
|
||||
--- request
|
||||
GET /lua
|
||||
--- response_body
|
||||
a = true
|
||||
b = true
|
||||
|
||||
|
||||
|
||||
=== TEST 46: ngx.decode_args (empty value args)
|
||||
--- config
|
||||
location /lua {
|
||||
content_by_lua '
|
||||
local args = "a=&b="
|
||||
args = ngx.decode_args(args)
|
||||
ngx.say("a = ", args.a)
|
||||
ngx.say("b = ", args.b)
|
||||
';
|
||||
}
|
||||
--- request
|
||||
GET /lua
|
||||
--- response_body
|
||||
a =
|
||||
b =
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче