]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
httplib test for early eof response. related to Issue13684
authorSenthil Kumaran <senthil@uthcode.com>
Sun, 29 Apr 2012 02:20:46 +0000 (10:20 +0800)
committerSenthil Kumaran <senthil@uthcode.com>
Sun, 29 Apr 2012 02:20:46 +0000 (10:20 +0800)
Lib/test/test_httplib.py

index ff033215b34795f7794ec72ff365e70287b60a6a..7c6c5bccf49f5370594836bdd9aa0995b8f2a7de 100644 (file)
@@ -369,6 +369,15 @@ class BasicTest(TestCase):
         resp.begin()
         self.assertRaises(client.LineTooLong, resp.read)
 
+    def test_early_eof(self):
+        # Test httpresponse with no \r\n termination,
+        body = "HTTP/1.1 200 Ok"
+        sock = FakeSocket(body)
+        resp = client.HTTPResponse(sock)
+        resp.begin()
+        self.assertEqual(resp.read(), b'')
+        self.assertTrue(resp.isclosed())
+
 class OfflineTest(TestCase):
     def test_responses(self):
         self.assertEqual(client.responses[client.NOT_FOUND], "Not Found")