fix: Filter out Accept-Encoding header in request passthrough to prevent compression
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user