Skip to content

fix(network): do not add empty entries to headers when looking up a missing header - #3243

Closed
Mohammed Alkindi (MohammedAlkindi) wants to merge 1 commit into
microsoft:mainfrom
MohammedAlkindi:fix/network-raw-headers-missing-key
Closed

Mohammed Alkindi (MohammedAlkindi) wants to merge 1 commit into
microsoft:mainfrom
MohammedAlkindi:fix/network-raw-headers-missing-key

Conversation

@MohammedAlkindi

Copy link
Copy Markdown
Contributor

Summary

  • response.header_value("x-missing") returned None but left an x-missing: None entry behind, so a later all_headers() listed it. RawHeaders.get_all indexed its defaultdict, which inserts on every miss. It now uses .get(name, {}), so lookups no longer change the headers. Async and sync tests cover the lookups on both Response and Request.

Fixes microsoft/playwright#43306

…issing header

RawHeaders.get_all indexed a defaultdict, which inserted an empty entry for every missing name. A later all_headers() then returned that name with a None value.
@pavelfeldman

Copy link
Copy Markdown
Member

Please remove the tests and add use case to an existing test.

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