【发布时间】:2019-11-05 22:30:48
【问题描述】:
我正在为kong 编写一个自定义插件。该插件将根据我的服务器转换请求/响应。我收到[info] 27#0: *588 client <x> closed keepalive connection。
经过一番调试,发现每次设置
ngx.arg[1] 与我转换后的回复。我已经按照kong提供的现有response-transformer插件。
这是kong body_filter 函数的主体:
local ctx = ngx.ctx
local chunk, eof = ngx.arg[1], ngx.arg[2]
ctx.rt_body_chunks = ctx.rt_body_chunks or {}
ctx.rt_body_chunk_number = ctx.rt_body_chunk_number or 1
if eof then
local someChunks = concat(ctx.rt_body_chunks)
local aBody = responseTransformer.transform(theConf, someChunks)
aBody = unEscapeString(aBody)
ngx.arg[1] = aBody or someChunks
else
ctx.rt_body_chunks[ctx.rt_body_chunk_number] = chunk
ctx.rt_body_chunk_number = ctx.rt_body_chunk_number + 1
ngx.arg[1] = nil
end
我使用本地虚拟服务器运行相同的插件。它工作正常。但是当我代理到我的实际服务器时,我收到了closed keepalive connection 错误。
从 kong 日志中,我可以看到响应已正确转换。
使用curl,我得到了大约一半的响应。
【问题讨论】:
标签: keep-alive kong