From 3a724b822d6ac989de8394078a81edb4cf2c5df4 Mon Sep 17 00:00:00 2001 From: XiaoLi Date: Sun, 28 Aug 2022 22:41:06 +0800 Subject: [PATCH] update return as r-d-e json --- scripts/lib/upyun_download.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/lib/upyun_download.lua b/scripts/lib/upyun_download.lua index 68fcaa1..70da58e 100644 --- a/scripts/lib/upyun_download.lua +++ b/scripts/lib/upyun_download.lua @@ -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 \ No newline at end of file