Commit 5bd67d0a by Seefs Committed by GitHub

Merge pull request #3130 from feitianbubu/pr/ce221d98d71ab7aec3eb60f27ca33dbb4dc9610a

fix: fetch model add header passthrough rule key check
parents 5df8b34f 42500b33
...@@ -13,6 +13,7 @@ import ( ...@@ -13,6 +13,7 @@ import (
"github.com/QuantumNous/new-api/constant" "github.com/QuantumNous/new-api/constant"
"github.com/QuantumNous/new-api/dto" "github.com/QuantumNous/new-api/dto"
"github.com/QuantumNous/new-api/model" "github.com/QuantumNous/new-api/model"
relaychannel "github.com/QuantumNous/new-api/relay/channel"
"github.com/QuantumNous/new-api/relay/channel/gemini" "github.com/QuantumNous/new-api/relay/channel/gemini"
"github.com/QuantumNous/new-api/relay/channel/ollama" "github.com/QuantumNous/new-api/relay/channel/ollama"
"github.com/QuantumNous/new-api/service" "github.com/QuantumNous/new-api/service"
...@@ -183,6 +184,9 @@ func buildFetchModelsHeaders(channel *model.Channel, key string) (http.Header, e ...@@ -183,6 +184,9 @@ func buildFetchModelsHeaders(channel *model.Channel, key string) (http.Header, e
headerOverride := channel.GetHeaderOverride() headerOverride := channel.GetHeaderOverride()
for k, v := range headerOverride { for k, v := range headerOverride {
if relaychannel.IsHeaderPassthroughRuleKey(k) {
continue
}
str, ok := v.(string) str, ok := v.(string)
if !ok { if !ok {
return nil, fmt.Errorf("invalid header override for key %s", k) return nil, fmt.Errorf("invalid header override for key %s", k)
......
...@@ -100,6 +100,9 @@ func getHeaderPassthroughRegex(pattern string) (*regexp.Regexp, error) { ...@@ -100,6 +100,9 @@ func getHeaderPassthroughRegex(pattern string) (*regexp.Regexp, error) {
return compiled, nil return compiled, nil
} }
func IsHeaderPassthroughRuleKey(key string) bool {
return isHeaderPassthroughRuleKey(key)
}
func isHeaderPassthroughRuleKey(key string) bool { func isHeaderPassthroughRuleKey(key string) bool {
key = strings.TrimSpace(key) key = strings.TrimSpace(key)
if key == "" { if key == "" {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment