fix: Prevent `_prepare_request_call` from mutating caller's headers dict (#746)
## Summary
`_prepare_request_call` in `HttpClientBase` was mutating the caller's
`headers` dict in place — the `if not headers: headers = {}` guard only
allocated a new dict when the caller passed `None`/empty, so a non-empty
caller-owned dict was mutated directly. Users of the documented custom
`HttpClient` / `HttpClientAsync` extension points that reuse a shared
headers dict across `call()` invocations would see stale `Content-Type`
/ `Content-Encoding` headers leak into subsequent requests (e.g. a
bodyless `GET` carrying `Content-Encoding: gzip` from a prior `POST`).
Fix: copy up-front with `headers = dict(headers) if headers else {}`.
Added a regression test covering the aliased-dict case.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> V
Vlada Dusek committed
d5531621535f5a491be5b5791ea4b80e46de1405
Parent: 6c3b84d
Committed by GitHub <noreply@github.com>
on 4/21/2026, 8:52:52 AM