Error calling BaseHTTPRequestHandler.end_headers()
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
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
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 CPython's BaseHTTPRequestHandler.end_headers() and compare its handling with flush_headers(), especially the _headers_buffer guard described in the report. Done means calling end_headers() without queued headers or a response completes without exposing an AttributeError; check linked PR gh-131718 before starting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100