Compare commits
2 Commits
ab48c8532c
...
9ad2c1f1bb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ad2c1f1bb | ||
|
|
4f44976214 |
@@ -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 {
|
||||
@@ -120,7 +120,8 @@ func setupKillcodeHeaders(c *gin.Context, req *http.Header) {
|
||||
req.Set("User-Agent", "B2/JS 0.51.0")
|
||||
req.Set("Connection", "keep-alive")
|
||||
req.Set("Accept", "application/json")
|
||||
req.Set("Accept-Encoding", "br, gzip, deflate")
|
||||
// 移除压缩请求头,避免 gzip 解析问题
|
||||
// req.Set("Accept-Encoding", "br, gzip, deflate")
|
||||
req.Set("Content-Type", "application/json")
|
||||
|
||||
// Stainless SDK 特有头部
|
||||
@@ -144,9 +145,9 @@ func setupKillcodeHeaders(c *gin.Context, req *http.Header) {
|
||||
req.Set("anthropic-beta", anthropicBeta)
|
||||
}
|
||||
|
||||
// 其他辅助头部
|
||||
// 其他辅助头部 (移除可能导致问题的头部)
|
||||
req.Set("accept-language", "*")
|
||||
req.Set("sec-fetch-mode", "cors")
|
||||
// req.Set("sec-fetch-mode", "cors") // 移除浏览器特有头部
|
||||
}
|
||||
|
||||
func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayInfo, request *dto.GeneralOpenAIRequest) (any, error) {
|
||||
|
||||
Reference in New Issue
Block a user