Files
magpie/internal/catalog
yetone 7450fa5f27 provider: a request header typed in lower case is sent once and is the user's, on the model list, the tests and requests (#1487, Dudung1018)
A provider's own headers were written into the request as typed
(req.Header[k] = …) to keep their case, beside magpie's own written with
Header.Set under the canonical name. A "user-agent" or "authorization"
typed in lower case, as devtools show headers, therefore went out next
to magpie's: two User-Agents, magpie's (or Go's Go-http-client/1.1, which
Go's HTTP/1 writer adds when it finds no canonical "User-Agent") first.
The reporter's relay checks the client and answered every probe 401
"unauthorized client detected", so the headers looked ignored.

catalog.PutUserHeader now takes every header of the same name in any
case off before writing the user's, and keeps User-Agent under its
canonical name so Go adds none. It is used everywhere the provider's
headers are applied as typed: Sign (forwarded calls, endpoint tests,
detection), the model lists (catalog FetchURL/FetchAt, Gemini pages),
Kilo's list and the Gemini image path. Azure's list merge drops an
api-key of another case too. The balance read already used Header.Set.

Run: curl against the reporter's relay (ps.air-outer.com, HTTP/1.1):
User-Agent "claude-cli/2.1.0 (external, cli)" alone gets past its client
check (to "无效的令牌" for a fake key); curl/8, or Go-http-client/1.1
ahead of the claude-cli one, gets "unauthorized client detected". A
scratch Go client confirmed Go sends "User-Agent: Go-http-client/1.1"
beside a lower-case "user-agent". TestUserHeadersInLowerCaseAreSentOnce
(HTTP/1.1 httptest server that refuses two User-Agents or two
Authorizations) fails without the change on list, endpoints and detect
(User-Agent ["Go-http-client/1.1" "claude-cli/…"], Authorization
["Bearer sk-test" "Bearer relay-own"]) and passes with it. Not tried
through a built magpie against the relay with the reporter's key.
2026-10-10 18:31:32 +08:00
..
catalog: a model the provider's catalog doesn't list is named as the other providers name it (John on Discord #feedback: GLM Coding Plan and ZCode name the same models in different case, in the provider list and the group picker) — the Coding Plan's /models (open.bigmodel.cn and api.z.ai, read with a real key) gives ids alone, glm-5-turbo, glm-5.3-flashx …; catalog.Decorate names only those Zhipu's models.dev entry (zhipuai) lists, so glm-5-turbo kept its id as its name beside ZCode's GLM-5-Turbo. models.dev's load now keeps each model's name as most providers serving it give it (a name that is only the id casts no vote), catalog.NameOf reads it by bare id in any case, and catalog.Named fills it in for a model still named by its id: in Available's live list and for a pick the list doesn't have. Ids, and what is sent upstream, are unchanged; a name the user gave stays theirs (Catalog's Name, with the new one as Default); an Azure provider is left out, its deployments named as their owner named them. TestModelNamedAsElsewhere (the Coding Plan's real ids, a user name, an Azure deployment) fails without the provider change and passes; TestNameOf is new. TestSearcherChosen read whatever catalog an earlier test had left loaded, and now resets it: with none, its lists' models go by their ids, as it expects. go test ./internal/catalog/ ./internal/provider/ ./internal/gateway/ ./internal/gui/ . pass; -race -count=5 for the two new tests; go vet, linux(nogui)/windows builds pass. No GUI change (the GUI and the group picker show name || id).
2026-10-06 13:09:40 +08:00