update return as r-d-e json
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user