rpc: canonicalize header keys in WithHeaders

WithHeaders assigned header keys verbatim, unlike WithHeader which
uses Header.Set and canonicalizes keys. Normalize keys to avoid
duplicate headers with different casing.
This commit is contained in:
Weixie Cui 2026-07-05 23:25:15 +08:00
parent e3b6d0c86f
commit 0bd3cfbf0c

View file

@ -92,7 +92,7 @@ func WithHeaders(headers http.Header) ClientOption {
return optionFunc(func(cfg *clientConfig) {
cfg.initHeaders()
for k, vs := range headers {
cfg.httpHeaders[k] = vs
cfg.httpHeaders[http.CanonicalHeaderKey(k)] = vs
}
})
}