python / python/cpython

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

未關閉
#153,648 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

stdlib type-feature
主要語言
Python
星號
77.2k
分支
35.9k
PR 合併指標
PR 指標待擷取

描述

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

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

首先定位 http.client.HTTPMessage.getallmatchingheaders(),並查看 gh-153649 中的相關工作,以及 issue 中提到的原 CGIHTTPRequestHandler 使用者。完成標準是將該方法標記為 Python 3.16 中棄用,並在 3.18 中移除,同時不移除文件化的 HTTPMessage 類別。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
backend
Issue 類型
重構
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
描述清楚
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。