Commit d553162
fix: Prevent
## 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>_prepare_request_call from mutating caller's headers dict (#746)1 parent 6c3b84d commit d553162
2 files changed
Lines changed: 19 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
207 | | - | |
208 | | - | |
| 207 | + | |
209 | 208 | | |
210 | 209 | | |
211 | 210 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
383 | 401 | | |
384 | 402 | | |
385 | 403 | | |
| |||
0 commit comments