Skip to content

Error calling BaseHTTPRequestHandler.end_headers() #131715

Open
@jnewbigin

Description

@jnewbigin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions