[New-bugs-announce] [issue43474] http.server.BaseHTTPRequestHandler end_header() fails

grumblor report at bugs.python.org
Thu Mar 11 06:09:59 EST 2021


New submission from grumblor <gitgrumblor at gmail.com>:

Python Version 3.8
http.server version 0.6
This is current install in new xubuntu 20.04 LTS, no idea if this is fixed in other version but appears to be present on github 
https://github.com/python/cpython/blob/3.9/Lib/http/server.py
at line 525

http.server.BaseHTTPRequestHandler end_headers() can reference _header_buffer array before it is assigned.

Should this be updated to something like the following? This fixes the problem of end_headers() failing for me:


    def end_headers(self):
        if not hasattr(self, '_headers_buffer'):
            self._headers_buffer = []
        """Send the blank line ending the MIME headers."""
        if self.request_version != 'HTTP/0.9':
            self._headers_buffer.append(b"\r\n")
            self.flush_headers()


This is my first issue, apologies for any mistakes I might have made.

----------
components: Library (Lib)
messages: 388498
nosy: grumblor
priority: normal
severity: normal
status: open
title: http.server.BaseHTTPRequestHandler  end_header() fails
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43474>
_______________________________________


More information about the New-bugs-announce mailing list