Commit Graph
2 Commits
Author SHA1 Message Date
yetone 73528a9a03 gateway: x-bili- headers go only to a /bili/ URL of the user's own provider (#3052)
Review of 5d5a148ab: it sent every x-bili- header the agent sent to every
provider, Claude and Codex accounts and every vendor included. They are
the billion-context proxy's own headers, so they now go on only when the
request's URL is in bili's prefix form (http://host:8787/bili/<upstream>,
the form its README gives for putting it in front of a gateway and the
one the report uses), and never for a signed-in account.

TestForwardOnceKeepsBiliHeadersFromOthers: a plain URL, a URL with
/bili/ deeper in its path, and an account on a /bili/ URL get none.
TestForwardOnceCarriesBiliHeaders now posts to a /bili/ URL.

Run on mote: go test -run 'TestForwardOnce(Carries|Keeps)BiliHeaders'
./internal/gateway, ok. Broken by hand: the condition set to true, and
the new test fails for all three requests.
Not tried: a real bili proxy.
2026-11-01 10:22:57 +08:00
ggbdpq ee031e9539 gateway: a billion-context proxy in front of the provider gets the client's x-bili- headers (#3052)
What changed: forwardOnce copies the client's x-bili-* headers on to the
request it builds for the provider, by a biliHeader predicate beside
claudeCodeHeader and codexClientHeader — an x-bili- prefix, in the shape
of the anthropic-, x-stainless-, x-claude-code-, x-openai- and x-codex-
families already on the allowlist. The headers carry the cooperative
plugin's name, conversation and context window, never a key; a header no
family allowlists, and the client's own key, still stay off.

Why: forwardOnce builds the upstream request from nothing and copies only
allowlisted headers, so a client talking to a billion-context (bili)
proxy put in front of its provider lost the x-bili- ones that name its
cooperative session — bili then saw an anonymous session and injected a
duplicate set of compression tools beside the plugin's own (#3052).
Whether to generalize this into a per-provider "pass-through client
headers" setting, beside PassUserAgent (#1851) and a provider's own
Headers, is the maintainer's call; this change only admits the family
the issue reports.

Run: go test -run TestForwardOnceCarriesBiliHeaders ./internal/gateway
fails on the baseline with the three headers empty and passes with the
change (httptest, no network); ablation (product file back at baseline,
test kept) fails again. gofmt -l clean; go vet ./..., GOOS=linux and
GOOS=windows go vet -tags nogui ./... clean; native, GOOS=linux -tags
nogui and GOOS=windows builds clean; go test -tags nogui
./internal/gateway green.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 10:22:56 +08:00