Skip to content

fix(network): do not add missing headers when looking them up - #3246

Open
Pavel Feldman (pavelfeldman) wants to merge 2 commits into
mainfrom
fix-playwright-43306
Open

Pavel Feldman (pavelfeldman) wants to merge 2 commits into
mainfrom
fix-playwright-43306

Conversation

@pavelfeldman

@pavelfeldman Pavel Feldman (pavelfeldman) commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

RawHeaders kept its headers in a defaultdict(dict), and get_all indexed it directly. Every lookup of a missing name stored an empty entry, so after response.header_value("x-missing") the header showed up in all_headers() as None. This affected header_value and header_values on both Request and Response.

The map is now a plain dict, filled with setdefault, and get_all reads it with .get. Lookups no longer change it. This takes the approach of #3243 a step further by dropping the defaultdict altogether.

Test: the existing test_response_headers_should_work now also looks up a missing header and checks that all_headers() doesn't gain it. It fails without the fix and passes on chromium, firefox and webkit, along with the rest of test_network.py.

Fixes: microsoft/playwright#43306

@pavelfeldman
Pavel Feldman (pavelfeldman) marked this pull request as ready for review October 12, 2026 22:45

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Python header_value() on a missing header adds it to all_headers() as None

2 participants