在获取post请求体时发生的错误,苦寻无果,求助!

37 views
Skip to first unread message

zz k

unread,
Jul 26, 2019, 5:57:08 AM7/26/19
to openresty
 access_by_lua_block {


               
if "GET" == ngx.var.request_method then
                    args
,err = ngx.req.get_uri_args()
                   
if err or not args['appKey'] or not args['appSecret'] then
                        ngx
.var.access = 0
                       
return
                   
end

               -- 如果args增加local变为本地变量,这里调用args会为nil。


                elseif
"POST" == ngx.var.request_method then
                    ngx
.req.read_body()
                   
-- args  = ngx.req.get_post_args()
                    args
= ngx.req.get_body_data()
                   
if not args['appKey'] or not args['appSecret'] then
                        ngx
.var.access = 0
                       
return
                   
end
               
end
}

1.png



这是配置文件,想要完成判断请求并获取请求体中的内容,在使用GET请求时,曾经在变量args前增加local,然后发现args只能在if中调用才有数据。在使用POST时,在日志文件中发现了图中错误,不知道是由于什么问题产生的,谢谢您的帮助。

zz k

unread,
Jul 26, 2019, 5:59:20 AM7/26/19
to openresty
补充一下图中的日志信息
2019/07/26 17:41:39 [error] 6361#6361: *59 "/home/xxx/work/html/index.html" is forbidden (13: Permission denied), client: 172.16.1.59, server: , request: "POST / HTTP/1.1", host: "172.16.0.38:7088"
2019/07/26 17:41:39 [error] 6361#6361: *59 "/home/xxx/work/html/index.html" is forbidden (13: Permission denied), client: 172.16.1.59, server: , request: "POST / HTTP/1.1", host: "172.16.0.38:7088"




在 2019年7月26日星期五 UTC+8下午5:57:08,zz k写道:
Reply all
Reply to author
Forward
0 new messages