From: Serhiy Storchaka Date: Wed, 6 Feb 2013 08:37:19 +0000 (+0200) Subject: Issue #16723: httplib.HTTPResponse no longer marked closed when the connection X-Git-Tag: v3.4.0a1~1434 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=daf990f8a79820e6e91ab5fa98a873e179d7602f;p=python Issue #16723: httplib.HTTPResponse no longer marked closed when the connection is automatically closed. --- daf990f8a79820e6e91ab5fa98a873e179d7602f diff --cc Lib/test/test_httplib.py index be2d77160c,db123dcb56..a2f141ec5e --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@@ -590,29 -609,10 +611,32 @@@ class BasicTest(TestCase) resp.begin() self.assertEqual(resp.read(), b'') self.assertTrue(resp.isclosed()) + self.assertFalse(resp.closed) + resp.close() + self.assertTrue(resp.closed) + def test_delayed_ack_opt(self): + # Test that Nagle/delayed_ack optimistaion works correctly. + + # For small payloads, it should coalesce the body with + # headers, resulting in a single sendall() call + conn = client.HTTPConnection('example.com') + sock = FakeSocket(None) + conn.sock = sock + body = b'x' * (conn.mss - 1) + conn.request('POST', '/', body) + self.assertEqual(sock.sendall_calls, 1) + + # For large payloads, it should send the headers and + # then the body, resulting in more than one sendall() + # call + conn = client.HTTPConnection('example.com') + sock = FakeSocket(None) + conn.sock = sock + body = b'x' * conn.mss + conn.request('POST', '/', body) + self.assertGreater(sock.sendall_calls, 1) + class OfflineTest(TestCase): def test_responses(self): self.assertEqual(client.responses[client.NOT_FOUND], "Not Found") diff --cc Misc/NEWS index 6bb65264b6,b7f121455b..f69e7e7a5c --- a/Misc/NEWS +++ b/Misc/NEWS @@@ -235,9 -163,9 +235,12 @@@ Core and Builtin Library ------- + - Issue #16723: httplib.HTTPResponse no longer marked closed when the connection + is automatically closed. + +- Issue #15359: Add CAN_BCM protocol support to the socket module. Patch by + Brian Thorne. + - Issue #16948: Fix quoted printable body encoding for non-latin1 character sets in the email package.