You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Istio Envoy Filter Lua修改响应体后Postman无响应问题排查

Envoy Lua过滤器修改响应体后客户端无限等待,日志已记录响应但Postman收不到内容

我参考Stack Overflow上的「envoy filter to intercept upstream response」教程创建了Envoy Filter,该过滤器已部分生效:HTTPS请求能被拦截,修改后的响应也能在日志中打印。但Postman一直无限等待,无法收到响应,而访问日志中已记录400响应,想了解为何Postman收不到响应体。

附上我的Envoy Filter配置:

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: test-http-filter
  namespace: test
spec:
  workloadSelector:
    labels:
      app: istio
  configPatches:
  - applyTo: HTTP_FILTER
    match:
      context: GATEWAY
      listener:
        filterChain:
          filter:
            name: envoy.filters.network.http_connection_manager
            subfilter: 
              name: envoy.filters.http.router
    patch:
      operation: INSERT_AFTER  # INSER_BEFORE also tried
      value: 
       name: envoy.custom-resp
       typed_config:
          "@type": "type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua"
          inlineCode: |
            function envoy_on_response(response_handle) 
                  if response_handle:headers():get(":status") == "404" or response_handle:headers():get(":status") == "400" then
                    local body = response_handle:body()
                    local jsonString = tostring(body:getBytes(0, body:length()))
                    response_handle:logErr("Status: "..response_handle:headers():get(":status"))
                    response_handle:logErr("JSONString: "..jsonString)
                    jsonString = jsonString:gsub("mystring", "myUpdatedstring")
                    response_handle:body():setBytes(jsonString)
                  end
                end

我使用response_handle:body():setBytes()时遇到此问题,原教程中的response_handle():set()在我的环境中会报错,请问有人遇到过类似问题吗?

内容的提问来源于stack exchange,提问作者NewBee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.26 03:03:31