You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Header Default rules and the move from the User-Agent environment variable are implemented consistently. Two narrow edge cases remain: a multi-value User-Agent whose first value is blank, and a default rule named __proto__ in the classic editor. Both are low impact and can be fixed before or shortly after merge.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
标题“feat(headers): 用通用兜底规则替代 UA 专用配置”概括了主要变更:新增 header_rules.default 通用兜底操作,并移除 UPSTREAM_USER_AGENT_FALLBACK 这一 UA 专用配置。标题与变更集直接相关,聚焦于核心意图。标题使用 Conventional Commits 格式,属于可接受的风格,不影响判定。
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
- if strings.TrimSpace(spec.Header.Get("User-Agent")) != "" {- return spec+ for _, ua := range spec.Header.Values("User-Agent") {+ if strings.TrimSpace(ua) != "" {+ return spec+ }
}
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue / Related Issue
Related: #963
变更内容 / Change Content
@tbphp 感谢之前在 #963 中的讨论。进一步考虑后,我认可将这类需求统一放在系统/分组请求头规则中的方向,不必为 User-Agent 单独增加一个配置入口。
这个 PR 在现有“设置/移除”旁增加“兜底”,用于只补齐缺失或空值,不覆盖客户端已有的非空请求头。例如
User-Agent兜底为Go-http-client/1.1,既保留正常客户端身份,也能覆盖无 UA 的请求以及服务端发起的凭据探测和模型发现。请帮忙审核这种通用方案是否更符合项目的设计。功能范围
header_rules.default,系统和分组均可配置;经典/新版界面都可编辑、保存和回读。${API_KEY}替换、错误摘要脱敏以及探测配置签名。替换 #963(有意的 RC 配置变更)
本 PR 完整撤回 #963 中新增的
UPSTREAM_USER_AGENT_FALLBACK示例、环境变量解析/配置字段、容器注入、执行器及 WebSocket 参数传递、相关专用测试和三语环境变量表说明,不保留兼容分支。使用旧变量的 RC 用户需要在升级时改用系统或分组的请求头兜底规则。没有自定义兜底规则时,原有内置
GPT-Load/<version>UA 行为不变。此 PR 不撤销 #964 的 OpenAI Audio Speech 支持。示例:
{ "header_rules": { "set": {}, "remove": [], "default": { "User-Agent": "Go-http-client/1.1" } } }验证
make check已通过(Go 格式/tidy/vet/全量单测、前端 lint/format/类型检查/构建、Go 构建和 diff 检查)。使用项目要求的 Node 24.18.0、pnpm 11.17.0 和标准 Go 缓存。自查清单 / Checklist
make check,或在说明中写明无法运行的原因和未验证范围。 / I ranmake check, or documented why it could not run and what remains unverified.