python / python/cpython

Error calling BaseHTTPRequestHandler.end_headers()

未關閉
#131,715 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

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

描述

Bug report

Bug description:

If a call is made to BaseHTTPRequestHandler.end_headers() but no headers or response have been queued, an exception is raised exposing implementation details.

    class request_handler(BaseHTTPRequestHandler):
        def do_GET(self):
            self.end_headers()

Actual result

AttributeError("'request_handler' object has no attribute '_headers_buffer'")

Expected result:

pass

flush_headers has a guard to check if the buffer has been allocated which is missing from end_headers

if hasattr(self, '_headers_buffer'):
CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs
  • gh-131718

貢獻指南

開啟貢獻指南

從這裡開始

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

研究方向

首先定位 CPython 的 BaseHTTPRequestHandler.end_headers() 並將其處理方式與 flush_headers() 進行比較,尤其要檢查報告中描述的 _headers_buffer 保護。完成的標準是:在沒有排隊的標頭或 response 的情況下呼叫 end_headers(),能夠完成且不會暴露 AttributeError;開始前請檢查關聯的 PR gh-131718。

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

評估

技術堆疊
python
領域
networking
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

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

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