Commit d0a7526
fix(datastructures): extend_header_value only reads the first duplicate header entry, dropping the rest
`extend_header_value()` used `self.get(key)` to read the existing value
before joining in the new one. `MutableMapping.get()` is backed by
`__getitem__`, which returns only the FIRST raw header entry matching
`key` -- but a header can legitimately appear as multiple separate raw
entries in `self.headers` (see `add()`'s own docstring: "This method
keeps duplicates"), not just as one comma-joined value.
Concrete failure: add two raw "vary" entries ("accept", "accept-encoding"),
then extend_header_value("vary", "user-agent") -- the result silently
drops "accept-encoding" entirely, leaving only "accept,user-agent".
Fix: use `getall()` instead of `get()` to collect ALL duplicate entries,
flattening each entry's own comma-separated list (matching the existing
single-entry behavior) before joining in the new value. `getall()`
currently raises `KeyError` when the header isn't present at all (a
separate falsy-default bug also present in this method, which I've
already reported/fixed independently in PR #4924) -- catching that
`KeyError` here keeps this fix correct regardless of merge order
between the two PRs.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 4a43322 commit d0a7526
2 files changed
Lines changed: 18 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
192 | | - | |
193 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
194 | 198 | | |
195 | 199 | | |
196 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
187 | 198 | | |
188 | 199 | | |
189 | 200 | | |
| |||
0 commit comments