# HG changeset patch # Parent 60b6e820abe5d196508e2c0ddcfdae72805b4afa Issue #26578: Override default_request_version in the HTTP 0.9 branch diff -r 60b6e820abe5 Lib/http/server.py --- a/Lib/http/server.py Fri Oct 28 19:01:46 2016 -0400 +++ b/Lib/http/server.py Sat Oct 29 00:41:09 2016 +0000 @@ -314,6 +314,7 @@ HTTPStatus.BAD_REQUEST, "Bad HTTP/0.9 request type (%r)" % command) return False + version = "HTTP/0.9" elif not words: return False else: diff -r 60b6e820abe5 Lib/test/test_httpservers.py --- a/Lib/test/test_httpservers.py Fri Oct 28 19:01:46 2016 -0400 +++ b/Lib/test/test_httpservers.py Sat Oct 29 00:41:09 2016 +0000 @@ -154,11 +154,17 @@ self.assertEqual(res.status, HTTPStatus.BAD_REQUEST) def test_version_none_get(self): + # Sends "GET / \r\n", with second space but empty version field self.con._http_vsn_str = '' + self.addCleanup(self.con.close) self.con.putrequest('GET', '/') self.con.endheaders() - res = self.con.getresponse() - self.assertEqual(res.status, HTTPStatus.NOT_IMPLEMENTED) + # This request is treated as a HTTP 0.9 request with version omitted, + # so the response is just HTML data + with self.con.sock.makefile('rb') as reader: + html = reader.read() + self.assertTrue(html.startswith(b'