Géry added the comment:
> http.server.BaseHTTPRequestHandler end_headers() can reference _header_buffer
> array before it is assigned.
@grumblor I was about to open the same bug after reading the implementation of
http.server this morning and noticing that the attribute _headers_buffer of
Andrei Kulakov added the comment:
It seems like sending zero headers is not supported, because:
- if using http/1.0
https://www.rfc-editor.org/rfc/rfc7230#section-6.1 -- Connection: close must
be sent
- if using http/1.1 --
Andrei Kulakov added the comment:
Why do you need to `end_headers()` before first doing `send_header()`?
I guess the normal use should be:
if headers:
for h in headers: send_header(h)
end_headers()
--
nosy: +andrei.avk
___
Python tracker
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
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