[issue43474] http.server.BaseHTTPRequestHandler end_header() fails

2021-03-11 Thread grumblor


New submission from grumblor :

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 
<https://bugs.python.org/issue43474>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43474] http.server.BaseHTTPRequestHandler end_header() fails

2021-03-11 Thread grumblor


grumblor  added the comment:

perhaps simply returning the method if _headers_buffer isn't defined is better 
since there is probably nothing to flush.

def end_headers(self):
if not hasattr(self, '_headers_buffer'):
return 1 
"""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()

--

___
Python tracker 
<https://bugs.python.org/issue43474>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com