Skip to content

Deprecate and remove http.client.HTTPMessage.getallmatchingheaders() #153648

Description

@soreavis

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions