]> granicus.if.org Git - python/commitdiff
fix handling of 100-continue status code (closes #18574)
authorBenjamin Peterson <benjamin@python.org>
Sun, 19 Jan 2014 02:50:18 +0000 (21:50 -0500)
committerBenjamin Peterson <benjamin@python.org>
Sun, 19 Jan 2014 02:50:18 +0000 (21:50 -0500)
Lib/http/server.py
Lib/test/test_httpservers.py
Misc/NEWS

index 2bfda12df43124366ff6e77f254f9c6558be39a8..7050b95352203cca45e639b2829807567cbc889a 100644 (file)
@@ -355,7 +355,7 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
 
         """
         self.send_response_only(100)
-        self.flush_headers()
+        self.end_headers()
         return True
 
     def handle_one_request(self):
index 9dd27788f750b303deaab2400da18465242c98e8..dfccb6bd6394efdb5be6f9dd04403fac12825e19 100644 (file)
@@ -563,7 +563,8 @@ class BaseHTTPRequestHandlerTestCase(unittest.TestCase):
     def test_with_continue_1_1(self):
         result = self.send_typical_request(b'GET / HTTP/1.1\r\nExpect: 100-continue\r\n\r\n')
         self.assertEqual(result[0], b'HTTP/1.1 100 Continue\r\n')
-        self.assertEqual(result[1], b'HTTP/1.1 200 OK\r\n')
+        self.assertEqual(result[1], b'\r\n')
+        self.assertEqual(result[2], b'HTTP/1.1 200 OK\r\n')
         self.verify_expected_headers(result[2:-1])
         self.verify_get_called()
         self.assertEqual(result[-1], b'<html><body>Data</body></html>\r\n')
@@ -631,7 +632,8 @@ class BaseHTTPRequestHandlerTestCase(unittest.TestCase):
         self.assertNotEqual(_readAndReseek(output), b'')
         result = _readAndReseek(output).split(b'\r\n')
         self.assertEqual(result[0], b'HTTP/1.1 100 Continue')
-        self.assertEqual(result[1], b'HTTP/1.1 200 OK')
+        self.assertEqual(result[1], b'')
+        self.assertEqual(result[2], b'HTTP/1.1 200 OK')
 
     def test_with_continue_rejected(self):
         usual_handler = self.handler        # Save to avoid breaking any subsequent tests.
index b831e491a223b960dd142437db6c1ae47c9aaa7f..0d2c13dc5d7643c415c0dd2867714ab01a461098 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -43,6 +43,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #18574: Fixed handling of 100-continue reply from server in
+  http.client.HTTPConnection. Patch by Nikolaus Rath.
+
 - Issue #20270: urllib.urlparse now supports empty ports.
 
 - Issue #20243: TarFile no longer raise ReadError when opened in write mode.