You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`function _M.before_proxy(conf, ctx)
local http_obj = http.new()
local res, err = get_response(ctx, http_obj)
if not res or err then
core.log.error("failed to request: ", err or "")
close(http_obj)
return 502
end
ctx.runner_ext_response = res
core.log.info("response info, status: ", res.status)
core.log.info("response info, headers: ", core.json.delay_encode(res.headers))
local code, body = ext.communicate(conf, ctx, name, constants.RPC_HTTP_RESP_CALL)
if body then
close(http_obj)
-- if the body is changed, the code will be set.
return code, body
end
core.log.info("ext-plugin will send response")
-- send origin response, status maybe changed.
err = send_response(ctx, res, code)
close(http_obj)
if err then
core.log.error(err)
return not ngx.headers_sent and 502 or nil
end
core.log.info("ext-plugin send response succefully")
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
ext-plugin启用后,在ext-plugin-post-resp.lua里的before_proxy函数里会直接调用http库向upstream发起访问获得返回并关闭连接,这导致非ext-plugin能使用的keepalive连接池在ext-plugin里无法生效,请问有什么解决方案吗?是否要自己在lua里实现一个keepalive连接池?:
`function _M.before_proxy(conf, ctx)
local http_obj = http.new()
local res, err = get_response(ctx, http_obj)
if not res or err then
core.log.error("failed to request: ", err or "")
close(http_obj)
return 502
end
ctx.runner_ext_response = res
end`
Beta Was this translation helpful? Give feedback.
All reactions