From 27e928f610462a10d9af85957fd60278f14e78ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E7=94=B7?= Date: Mon, 27 Jun 2022 03:34:10 +0800 Subject: [PATCH] close httpc --- scripts/create_task.lua | 3 +++ scripts/jwt_verify.lua | 2 ++ scripts/upload_audio.lua | 3 +++ scripts/wx_download.lua | 5 ----- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/create_task.lua b/scripts/create_task.lua index e81825d..9a8ce60 100644 --- a/scripts/create_task.lua +++ b/scripts/create_task.lua @@ -48,6 +48,9 @@ local function create_task(files, authHeader, sudoerToken) end ngx.say(res.body) + + httpc:close() + ngx.exit(res.status) end diff --git a/scripts/jwt_verify.lua b/scripts/jwt_verify.lua index a2837c1..946d153 100644 --- a/scripts/jwt_verify.lua +++ b/scripts/jwt_verify.lua @@ -50,6 +50,8 @@ local function verifyJwtToken(token) } ) + httpc:close() + if not res then ngx.log(ngx.ERR, "CAN'T VERIFY JWT TOKEN -> ", err) ngx.exit(ngx.HTTP_FORBIDDEN) diff --git a/scripts/upload_audio.lua b/scripts/upload_audio.lua index 0f76674..c7bbec4 100644 --- a/scripts/upload_audio.lua +++ b/scripts/upload_audio.lua @@ -40,6 +40,9 @@ local function create_task() body = body_text, } ) + + httpc:close() + if res == nil then ngx.log(ngx.ERR, "FAILED TO CONNECT TO *TASK_SERVER*", err) end diff --git a/scripts/wx_download.lua b/scripts/wx_download.lua index d8f18ef..076fa50 100644 --- a/scripts/wx_download.lua +++ b/scripts/wx_download.lua @@ -23,8 +23,6 @@ local function get_access_token() local no_exception, resp, resp_err = pcall(httpc.request_uri, httpc, remote_url, { ssl_verify = false, -- 设置参数 ssl_verify 为false 不校验ssl证书 - --pool = nil, - --pool_size = nil, method = "GET", headers = { ["HtyHost"] = wx_domain, @@ -39,11 +37,9 @@ local function get_access_token() ngx.log(ngx.ERR, "GET ACCESS TOKEN *FAILED*", pl.write(resp_err)) ngx.status = resp.status ngx.say(pl.write(resp_err)) - --httpc:close() ngx.exit(resp.status) else ngx.log(ngx.ERR, "RESP IS OK -> ", pl.write(resp.body)) - --httpc:close() return cjson.decode(resp.body).d end else @@ -55,7 +51,6 @@ local function get_access_token() -- https://github.com/openresty/lua-resty-redis/issues/15 ngx.status = 401 ngx.say(cjson.encode({r = false, d = "HtySudoerTokenErr"})) - --httpc:close() ngx.exit(401) end