fix: skip Accept-Encoding during header passthrough (#2214) - #2997
Conversation
WalkthroughAdded "accept-encoding" to the passthrough skip header set in the API request handler to prevent this header from being forwarded by passthrough rules. A corresponding test validates that the Accept-Encoding header is properly omitted while preserving other headers like X-Trace-Id. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
有你说的issues之前还没请求头透传功能呢。。。 |
|
我用了请求头透传,出现了这个问题 {"error":{"message":"invalid character '\x1f' looking for beginning of value","type":"bad_response_body","param":"","code":"bad_response_body"}} |
是你自己遇到的那可以,这个Issue关联我就去掉了,他和这个毫无关系。 |
…-encoding-passthrough fix: skip Accept-Encoding during header passthrough (QuantumNous#2214)
背景
开启请求头透传后,使用
curl请求可能报错:invalid character '\x1f' looking for beginning of value(bad_response_body)。根因
透传规则(
*/re:)把客户端Accept-Encoding也转发到了上游。在这种情况下,上游可能返回 gzip 压缩响应体,而当前链路会把该二进制内容按 JSON 解析,导致首字节
0x1f触发解析失败。修复内容
accept-encoding,避免通过通配/正则透传该头。TestProcessHeaderOverride_PassthroughSkipsAcceptEncoding,验证透传时会跳过Accept-Encoding。验证
go test ./relay/channel -run TestProcessHeaderOverride -count=1go test ./relay/channel -count=1影响范围
*/re:/regex:)。Summary by CodeRabbit