Skip to content

gh-153648: Deprecate http.client.HTTPMessage.getallmatchingheaders()#153649

Open
soreavis wants to merge 2 commits into
python:mainfrom
soreavis:deprecate-getallmatchingheaders
Open

gh-153648: Deprecate http.client.HTTPMessage.getallmatchingheaders()#153649
soreavis wants to merge 2 commits into
python:mainfrom
soreavis:deprecate-getallmatchingheaders

Conversation

@soreavis

@soreavis soreavis commented Jul 13, 2026

Copy link
Copy Markdown

getallmatchingheaders() has returned an empty list for every input since Python 3.0 — it compares keys() entries, which are bare header names, against "name:". Its only user was the CGI handler, which was removed in 3.15, and run_cgi() had already stopped calling it in 3.10.

Deprecate it, with removal in 3.18. That is PEP 387's minimum window rather than the usual five years, on the grounds that the method has never worked and has had no callers for five releases — happy to push it out to 3.21 if you'd rather keep it in line with the other 3.16 deprecations.

Use email.message.Message.get_all() instead.

#153648

…ers()

getallmatchingheaders() has returned an empty list for every input since
Python 3.0 -- it compares keys() entries, which are bare header names,
against "name:".  Its only user was the CGI handler, removed in 3.15, and
run_cgi() had already stopped calling it in 3.10.

Deprecate it, with removal in 3.18.  Use email.message.Message.get_all()
instead.
@read-the-docs-community

Copy link
Copy Markdown

@picnixz picnixz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good but just a nit.

Comment thread Lib/http/client.py
"""
import warnings
warnings._deprecated(
"http.client.HTTPMessage.getallmatchingheaders",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a "use XXX instead"?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call — done. The warning now reads:

'http.client.HTTPMessage.getallmatchingheaders' is deprecated and slated for removal in Python 3.18. Use email.message.Message.get_all() instead.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants