diff -r e548ab4ce71d Lib/http/__init__.py --- a/Lib/http/__init__.py Mon Feb 09 19:49:00 2015 +0000 +++ b/Lib/http/__init__.py Mon Feb 09 13:59:29 2015 -0800 @@ -24,6 +24,9 @@ obj.description = description return obj + def __str__(self): + return '{:d} ({:s})'.format(self, self.phrase) + # informational CONTINUE = 100, 'Continue', 'Request received, please continue' SWITCHING_PROTOCOLS = (101, 'Switching Protocols', diff -r e548ab4ce71d Lib/test/test_httpservers.py --- a/Lib/test/test_httpservers.py Mon Feb 09 19:49:00 2015 +0000 +++ b/Lib/test/test_httpservers.py Mon Feb 09 13:59:29 2015 -0800 @@ -6,7 +6,7 @@ from http.server import BaseHTTPRequestHandler, HTTPServer, \ SimpleHTTPRequestHandler, CGIHTTPRequestHandler -from http import server +from http import server, HTTPStatus import os import sys @@ -235,6 +235,27 @@ self.assertEqual(int(res.getheader('Content-Length')), len(data)) +class RequestHandlerLoggingTestCase(BaseTestCase): + class request_handler(BaseHTTPRequestHandler): + protocol_version = 'HTTP/1.1' + default_request_version = 'HTTP/1.1' + + def do_GET(self): + self.send_response(HTTPStatus.OK) + self.end_headers() + + def test_get(self): + self.con = http.client.HTTPConnection(self.HOST, self.PORT) + self.con.connect() + + with support.captured_stderr() as err: + self.con.request('GET', '/') + self.con.getresponse() + + self.assertTrue( + err.getvalue().endswith('"GET / HTTP/1.1" 200 (OK) -\n')) + + class SimpleHTTPServerTestCase(BaseTestCase): class request_handler(NoLogRequestHandler, SimpleHTTPRequestHandler): pass @@ -764,6 +785,7 @@ cwd = os.getcwd() try: support.run_unittest( + LoggingRequestHandlerTestCase, BaseHTTPRequestHandlerTestCase, BaseHTTPServerTestCase, SimpleHTTPServerTestCase,