saiyoofan commented on issue #6643:
URL: https://github.com/apache/apisix/issues/6643#issuecomment-1072231212
```
elseif core_str.has_prefix(key, "post_arg_") then
-- only match default post form
if request.header(nil, "Content-Type") ~= nil then
local con_t = sub_str(request.header(nil,
"Content-Type"),1,33)
if con_t == "application/x-www-form-urlencoded" then
local arg_key = sub_str(key, 10)
local args = request.get_post_args()[arg_key]
if args then
if type(args) == "table" then
val = args[1]
else
val = args
end
end
end
end
elseif core_str.has_prefix(key, "body_arg_") then
-- only match default body json
if request.header(nil, "Content-Type") ~= nil then
local con_t = sub_str(request.header(nil,
"Content-Type"),1,16)
if con_t == "application/json" then
local body, err = request.get_body()
if not body then
return nil, "failed to read body data, " .. (err or
"request body has zero size")
end
local arg_key = sub_str(key, 10)
local res
res, err = json.decode(body)
if not res then
return nil, "failed to read body data, " .. err
end
if not res[arg_key] then
return nil, "failed to read body data, json body[" ..
arg_key .. "] is nil"
end
val = res[arg_key]
end
end
```
The above code seems to work fine.
But I'm not sure if there will be other problems.
If you have better suggestions, I hope to help correct me, thank you
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]