Hello!
On Fri, Jan 29, 2016 at 10:30 PM, 罗厚付 wrote:
> stack traceback:
> coroutine 0:
> /opt/openresty/lua/test.lua: in function </opt/openresty/lua/test.lua:1>
> while sending to client, client: *.*.*.* , server: _, request: "POST
> /index.php HTTP/1.0", host: "*.*.*"
> 2016/01/28 23:27:36 [error] 15773#0: *16809007 lua entry thread aborted:
> runtime error: /opt/openresty/lua/test.lua:82: attempt to index local
> 'res1_body' (a userdata value)
>
>
> 81 local res1_body = cjson.decode(res1.body)
> 82 if res1_body and res1_body.code ~= 1 then
> 83 return print(res1.body)
> 84 end
貌似 cjson.decode() 返回了 ngx.null 值(这是一个 userdata),即 res1.body
的内容很可能是"null". 你的判断应该这么写:
if res1_body and res1_body ~= ngx.null and res1_body.code ~= 1 then
Regards,
-agentzh