update return as r-d-e json

This commit is contained in:
XiaoLi
2022-08-28 22:41:06 +08:00
committed by 阿男
parent 686c3f9775
commit 3a724b822d
+5 -2
View File
@@ -27,7 +27,8 @@ function _M.upyun_download(httpc, cjson, Upt, pl, uri)
if 200 ~= resp.status then
ngx.log(ngx.ERR, "UPYUN DOWNLOAD *FAILED*", pl.write(resp_err))
ngx.status = resp.status
ngx.say(pl.write(resp_err))
-- ngx.say(pl.write(resp_err))
ngx.say(cjson.encode({r = false, d = nil, e = resp_err}))
ngx.exit(resp.status)
else
ngx.log(ngx.ERR, "RESP IS OK -> ", pl.write(resp.body))
@@ -39,7 +40,7 @@ function _M.upyun_download(httpc, cjson, Upt, pl, uri)
end
ngx.log(ngx.ERR, "FAILED TO CONNECT TO *UPYUN*: httpc throws runtime error, please check log. / ", pl.write(resp))
ngx.status = resp.status
ngx.say(cjson.encode({r = false, d = "UpyunDownloadErr"}))
ngx.say(cjson.encode({r = false, d = nil, e = resp.status}))
ngx.exit(resp.status)
end
@@ -54,6 +55,8 @@ function _M.upyun_download(httpc, cjson, Upt, pl, uri)
f:write(resp.body)
f:close()
ngx.say(cjson.encode({r = true, d = "/tmp/test.jpg", e = nil}))
ngx.exit(resp.status)
end
return _M