| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Thanks - would you mind added a test and changelog entry? |
Sorry, something went wrong.
|
@bysiber Thanks for the fix - I think I understand the nuance here and added one new test to check against the fixed behaviour. Please let me know if this looks good to you! |
Sorry, something went wrong.
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.
| Back | FazBrowse Home | New Git URL |
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 check fails when value is b"" because empty bytes are falsy in Python.
46 of 61 static table entries have an empty value (:authority, accept-charset, accept-language, age, allow, authorization, cache-control, etc.). When encoding a header that perfectly matches one of those entries, the encoder falls through to the indexed-literal branch instead:
Expected: 81 (indexed representation, 1 byte, no dynamic table entry).
The indexed-literal path also calls self.header_table.add(name, value), which adds an unnecessary duplicate of the static entry to the dynamic table, wasting space and evicting useful entries.
This changes if perfect: to if perfect is not None:.