Commit 89cce96
Fix perfect match missed for headers with empty values
HeaderTable.search() returns (index, name, value) for perfect matches
and (index, name, None) for partial matches. The encoder distinguishes
them with `if perfect:`, but this fails when value is b"" because
empty bytes are falsy in Python.
46 of 61 static table entries have an empty value (e.g. :authority,
accept-charset, accept-language, age, allow, …). When encoding a
header that perfectly matches one of these entries, the encoder falls
through to the indexed-literal path — using 2+ bytes instead of 1 and
unnecessarily adding the entry to the dynamic table.
Change the check to `if perfect is not None:` so that b"" is treated
as a valid perfect match.1 parent 1621490 commit 89cce96
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
323 | | - | |
| 323 | + | |
324 | 324 | | |
325 | 325 | | |
326 | 326 | | |
| |||
0 commit comments