When the data is formData, the parsed out shows Instance of'FormData'
- Dominant language
- Lua
- Stars
- 56
- Forks
- 24
- PR merge metrics
- No merged PRs in 30d
Description
```log
2020/06/26 22:52:45 [info] 30346#30346: *4239 [lua] Princopal.lua:17: RW1OO7hAfPHdavccK2XBWYBSEScWpHzsudt3Pwh0oFFu4oOFMHq05dxQmVq9s+/f8nSgQ77mjySe6RwgF3N93t5+2ifJtjCrKG7lFnIhSNN7w8FQ19L+ny/bzIOyHLH0K5PsgW4k17QNP79TH0XCTk4YHeG+45Decw8Zv3iBkEPCMqVy5ByuYmImpz3ln3u/FXNiKXsFogz59p7KRGhvB33RJ41VymWBfSN4K3ls9RjEj2KIj6mZ4+lMXn+R7bKhCpAdL8/axriezTII/2NkBnzuXXPHG2iAO1qtjOUQkS0DEfqS/d6rQxT42dUSsCu/zM3S3q3ENLULkKUWA+O6dA==, client: 121.32.48.11, request: "POST /Princopal HTTP/1.1",
2020/06/26 22:52:45 [info] 30346#30346: *4239 [lua] Princopal.lua:19: Instance of 'FormData', client: 121.32.48.11, request: "POST /Princopal HTTP/1.1",
```
```lua
local cjson = require "cjson.safe" --Json解析模块
local resty_rsa = require "resty.rsa" --对称加密解密模块
local Multipart = require("multipart") --解析fromData表单
local method = ngx.req.get_method() --获取是Get还是Post
local private_file = io.open("/Nginx/lua/flutter_private.pem", "r") --打开私匙文件
local private_Key = private_file:read("*a") --读取私钥内容
local priv = resty_rsa:new({private_key = private_Key, key_type = resty_rsa.KEY_TYPE.PKCS1}) --创建一个 对象
local head = ngx.req.get_headers() --获取请求头
if method == "POST" then --如果是Post的话
ngx.req.read_body() --读取Post_Body
local Encryptionbody = ngx.req.get_body_data() --获取消息体,此时是被加密的消息体
ngx.log(ngx.INFO, Encryptionbody)
local body = priv:decrypt(ngx.decode_base64(Encryptionbody)) --解析出来,此时是真正的消息
ngx.log(ngx.INFO, body)
if body == nil then
ngx.exit(500)
end
local multipart_data = Multipart(body, head["content-type"])
body = multipart_data:tostring()
ngx.log(ngx.INFO, body)
--判断是Json格式还是其他的格式
-- local str = cjson.encode(priv:decrypt(ngx.decode_base64(body))) --解析消息体,然后转换为Json
if body then
ngx.say(body)
end
ngx.exit(200)
end
if method == "GET" then
end
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the supplied Princopal.lua example, especially Multipart(body, head["content-type"]) and multipart_data:tostring(), and reproduce the logged "Instance of 'FormData'" result with the encrypted multipart request. Compare the returned value with the expected parsed form fields; done should mean the parser returns usable multipart data instead of that representation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100