ymichaelson commented on issue #11977:
URL: https://github.com/apache/apisix/issues/11977#issuecomment-2684215762
> ### Current Behavior
> 开发了一个插件,修改了server返回的流式响应的请求体,apisix一次响应不是一个chunk,而是累积几个chunk一起响应
已经尝试在route和nginx关闭cache,没有效果。示例代码
>
> ### Expected Behavior
> 期望在修改响应体后,可以流式的返回响应体
>
> ### Error Logs
> _No response 无响应_
>
> ### Steps to Reproduce
> 1.启动apisix和etcd 2.配置文件中配置自定义插件 3.启动测试服务器,可以返回流式响应 4.配置route和upstream 插件代码示例
>
> local plugin_name = "extract-reasoning"
> local core = require("apisix.core")
> local cjson = require("cjson.safe")
> local ngx = ngx
>
> local schema = {
> type = "object",
> properties = {},
> }
>
> local _M = {
> version = 1.0,
> priority = 1000,
> name = plugin_name,
> schema = schema,
> }
>
>
> function _M.header_filter(conf, ctx)
> -- 设置SSE响应头
> ngx.header["Content-Type"] = "text/event-stream"
> -- ngx.header["Cache-Control"] = "no-cache"
> ngx.header["Connection"] = "keep-alive"
> ngx.header["Cache-Control"] = "no-cache, no-store, must-revalidate"
> ngx.header["Pragma"] = "no-cache"
> ngx.header["Expires"] = "0"
> end
>
> function _M.body_filter(conf, ctx)
> local chunk = ngx.arg[1]
> local is_last = ngx.arg[2]
>
> ngx.arg[1] = chunk
> end
>
> return _M
> ### Environment
> * APISIX version (run `apisix version`):APISIX 版本(运行 `apisix 版本`):
> * Operating system (run `uname -a`):作系统(运行 `uname -a`):
> * OpenResty / Nginx version (run `openresty -V` or `nginx -V`):OpenResty /
Nginx 版本(运行 `openresty -V` 或 `nginx -V`):
> * etcd version, if relevant (run `curl
http://127.0.0.1:9090/v1/server_info`):etcd 版本(如果相关)(运行 `curl
http://127.0.0.1:9090/v1/server_info` ):
> * APISIX Dashboard version, if relevant:APISIX Dashboard 版本(如果相关):
> * Plugin runner version, for issues related to plugin
runners:插件运行程序版本,用于与插件运行程序相关的问题:
> * LuaRocks version, for installation issues (run `luarocks
--version`):LuaRocks 版本,针对安装问题(运行 `luarocks --version`):
按照这个插件测试,没有达到预期的效果,还是累积多个chunk再返回,是还需要有什么配置吗?路由上已经配置了这个plugin
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]