fix
This commit is contained in:
@@ -4,7 +4,7 @@ package.path = package.path .. ';<SCRIPT_PATH>/?.lua';
|
||||
|
||||
local _M = {}
|
||||
|
||||
function _M.upyun_download(httpc, Upt, pl, uri)
|
||||
function _M.upyun_download(httpc, cjson, Upt, pl, uri)
|
||||
|
||||
ngx.log(ngx.INFO, "UPYUN DOWNLOAD : URI -> " .. uri)
|
||||
|
||||
@@ -22,6 +22,30 @@ function _M.upyun_download(httpc, Upt, pl, uri)
|
||||
method = "GET",
|
||||
})
|
||||
|
||||
ngx.log(ngx.INFO, "RESP -> ", pl.write(resp))
|
||||
if no_exception == true then
|
||||
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.exit(resp.status)
|
||||
else
|
||||
ngx.log(ngx.ERR, "RESP IS OK -> ", pl.write(resp.body))
|
||||
-- return cjson.decode(resp.body).d
|
||||
end
|
||||
else
|
||||
if resp == nil then
|
||||
resp = ""
|
||||
end
|
||||
ngx.log(ngx.ERR, "FAILED TO CONNECT TO *UPYUN*: httpc throws runtime error, please check log. / ", pl.write(resp))
|
||||
-- 必须先设置ngx.status,否则ngx.say之后就直接被设置为200了,不会再被exit设为401
|
||||
-- https://github.com/openresty/lua-resty-redis/issues/15
|
||||
ngx.status = 401
|
||||
ngx.say(cjson.encode({r = false, d = "UpyunDownloadErr"}))
|
||||
ngx.exit(401)
|
||||
end
|
||||
|
||||
|
||||
-- TODO: send resp.body to Flask API (ai-api) -> convert_mxml_to_xml() -> XML string
|
||||
-- local xml = ai-api.convert_mxml_to_xml(resp.body)
|
||||
-- ngx.log(xml)
|
||||
|
||||
Reference in New Issue
Block a user