From 9ad2c1f1bbb64ec39a73b7e8c93f6645785592ef Mon Sep 17 00:00:00 2001 From: huangzhenpc Date: Wed, 27 Aug 2025 10:25:03 +0800 Subject: [PATCH] fix: Filter out Accept-Encoding header in request passthrough to prevent compression MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed 'invalid character '\x1f' looking for beginning of value' error when sending images: - Added accept-encoding to filtered headers in complete passthrough mode - This prevents upstream from returning gzip compressed responses that new-api cannot parse - Issue occurred when clients (like image uploads) had compression headers passed through directly 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- relay/channel/claude/adaptor.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/relay/channel/claude/adaptor.go b/relay/channel/claude/adaptor.go index 06942912..1ea1419e 100644 --- a/relay/channel/claude/adaptor.go +++ b/relay/channel/claude/adaptor.go @@ -65,10 +65,10 @@ func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Header, info *rel // 智能请求头策略:检测客户端类型并决定处理方式 if isClaudeCode(userAgent) || isKillcode(userAgent) { - // Claude Code 和 killcode: 完全透传原始请求头 + // Claude Code 和 killcode: 完全透传原始请求头 (除了压缩头) for key, values := range c.Request.Header { keyLower := strings.ToLower(key) - if keyLower == "host" || keyLower == "content-length" || keyLower == "connection" { + if keyLower == "host" || keyLower == "content-length" || keyLower == "connection" || keyLower == "accept-encoding" { continue } for _, value := range values {