mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-04 13:07:34 +08:00
fix(ext-plugin): avoid using 0 as the default http status code (#4734)
This commit is contained in:
parent
8e72f3e718
commit
316d23074f
@ -431,7 +431,12 @@ local rpc_handlers = {
|
|||||||
end
|
end
|
||||||
body = ffi_str(body, len)
|
body = ffi_str(body, len)
|
||||||
end
|
end
|
||||||
return true, nil, stop:Status(), body
|
local code = stop:Status()
|
||||||
|
-- avoid using 0 as the default http status code
|
||||||
|
if code == 0 then
|
||||||
|
code = 200
|
||||||
|
end
|
||||||
|
return true, nil, code, body
|
||||||
end
|
end
|
||||||
|
|
||||||
if action_type == http_req_call_action.Rewrite then
|
if action_type == http_req_call_action.Rewrite then
|
||||||
|
@ -185,7 +185,9 @@ function _M.go(case)
|
|||||||
local vec = builder:EndVector(len)
|
local vec = builder:EndVector(len)
|
||||||
|
|
||||||
http_req_call_stop.Start(builder)
|
http_req_call_stop.Start(builder)
|
||||||
http_req_call_stop.AddStatus(builder, 405)
|
if case.check_default_status ~= true then
|
||||||
|
http_req_call_stop.AddStatus(builder, 405)
|
||||||
|
end
|
||||||
http_req_call_stop.AddBody(builder, b)
|
http_req_call_stop.AddBody(builder, b)
|
||||||
http_req_call_stop.AddHeaders(builder, vec)
|
http_req_call_stop.AddHeaders(builder, vec)
|
||||||
local action = http_req_call_stop.End(builder)
|
local action = http_req_call_stop.End(builder)
|
||||||
|
20
t/plugin/ext-plugin/http-req-call.t
vendored
20
t/plugin/ext-plugin/http-req-call.t
vendored
@ -517,3 +517,23 @@ GET /hello
|
|||||||
--- access_log
|
--- access_log
|
||||||
GET /plugin_proxy_rewrite_args%3Fa=2
|
GET /plugin_proxy_rewrite_args%3Fa=2
|
||||||
--- error_code: 404
|
--- error_code: 404
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
=== TEST 18: stop without setting status code
|
||||||
|
--- request
|
||||||
|
GET /hello
|
||||||
|
--- response_body chomp
|
||||||
|
cat
|
||||||
|
--- extra_stream_config
|
||||||
|
server {
|
||||||
|
listen unix:$TEST_NGINX_HTML_DIR/nginx.sock;
|
||||||
|
|
||||||
|
content_by_lua_block {
|
||||||
|
local ext = require("lib.ext-plugin")
|
||||||
|
ext.go({stop = true, check_default_status = true})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--- response_headers
|
||||||
|
X-Resp: foo
|
||||||
|
X-Req: bar
|
||||||
|
Loading…
Reference in New Issue
Block a user