New submission from Xiang Zhang:

BaseHTTPRequestHandler in http.server supports HTTP/0.9. But the response for 
HTTP/0.9 request is implemented wrong. 

Response of HTTP/0.9 request returns message body directly without status line 
and headers. But if you inherit BaseHTTPRequestHandler and set the 
default_request_version to "HTTP/1.x", then self.request_version can never be 
"HTTP/0.9" since in the 
https://hg.python.org/cpython/file/tip/Lib/http/server.py#l315 branch it does 
not set version to "HTTP/0.9" and then always sends the status line and headers 
back.

A trivial patch can fix this problem that set version to "HTTP/0.9" in the 
branch. But this will cause some failure in tests. The tests in 
test_httpservers use http.client.HTTPConnection to send and receive HTTP 
message. But since 3.4, HTTPConnection doesn't support HTTP/0.9-style simple 
responses. We can use it to test HTTP/0.9 connection if the server is 
implemented in the right way.

And since http.client.HTTPConnection has dropped the support for HTTP/0.9, is 
it reasonable to drop the support in http.server too?

----------
components: Library (Lib)
messages: 261898
nosy: xiang.zhang
priority: normal
severity: normal
status: open
title: Bad BaseHTTPRequestHandler response when using HTTP/0.9
versions: Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26578>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to