Deprecate and remove http.client.HTTPMessage.getallmatchingheaders()
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Splitting this out of #49303, as @hugovk suggested there.
HTTPMessage.getallmatchingheaders() has returned [] for every input since Python 3.0. It compares self.keys() entries against "name:", but keys() returns header names without the colon, so nothing ever matches:
>>> msg = email.parser.Parser(_class=http.client.HTTPMessage).parsestr("Set-Cookie: a=1\r\n")
>>> msg.get_all("Set-Cookie")
['a=1']
>>> msg.getallmatchingheaders("Set-Cookie")
[]
Its only consumer was CGIHTTPRequestHandler, which @picnixz removed in 3.15 (#133810). The method is undocumented and untested, and since it has never returned anything, no working code can depend on its output — so removing it carries no real compatibility risk.
The older patch on #49303 went further and dropped the whole HTTPMessage class, but that one is a documented public type (it's what response.headers is), so I'd suggest keeping this issue to the method.
Proposal: deprecate in 3.16, remove in 3.18. Happy to send the PR if that's the direction.
Linked PRs
- gh-153649
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating http.client.HTTPMessage.getallmatchingheaders() and review the linked work in gh-153649, along with the former CGIHTTPRequestHandler consumer mentioned in the issue. Done means deprecating the method for Python 3.16 and removing it in 3.18 without removing the documented HTTPMessage class.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100