This is an automated email from the ASF dual-hosted git repository. spacewander pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push: new 7c4f10e chore: check the error from get_post_args (#5537) 7c4f10e is described below commit 7c4f10e445618e30c538a6edce9ffd0da09b0816 Author: 罗泽轩 <spacewander...@gmail.com> AuthorDate: Thu Nov 18 11:57:56 2021 +0800 chore: check the error from get_post_args (#5537) --- apisix/core/request.lua | 7 ++++++- t/core/request.t | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/apisix/core/request.lua b/apisix/core/request.lua index f098f63..7d9bf80 100644 --- a/apisix/core/request.lua +++ b/apisix/core/request.lua @@ -161,7 +161,12 @@ function _M.get_post_args(ctx) -- use 0 to avoid truncated result and keep the behavior as the -- same as other platforms - local args = req_get_post_args(0) + local args, err = req_get_post_args(0) + if not args then + -- do we need a way to handle huge post forms? + log.error("the post form is too large: ", err) + args = {} + end ctx.req_post_args = args end diff --git a/t/core/request.t b/t/core/request.t index e9dca7b..06256dc 100644 --- a/t/core/request.t +++ b/t/core/request.t @@ -408,3 +408,32 @@ z_z x x --- no_error_log [error] + + + +=== TEST 12: get_post_args when the body is stored in temp file +--- config + location = /hello { + client_body_in_file_only clean; + content_by_lua_block { + local core = require("apisix.core") + local ngx_ctx = ngx.ctx + local api_ctx = ngx_ctx.api_ctx + if api_ctx == nil then + api_ctx = core.tablepool.fetch("api_ctx", 0, 32) + ngx_ctx.api_ctx = api_ctx + end + + core.ctx.set_vars_meta(api_ctx) + + local args = core.request.get_post_args(ngx.ctx.api_ctx) + ngx.say(args["c"]) + } + } +--- request +POST /hello +c=z_z&v=x%20x +--- response_body +nil +--- error_log +the post form is too large: request body in temp file not supported