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
相关产品推荐
相关产品推荐

