]> granicus.if.org Git - python/commitdiff
Issue #16723: httplib.HTTPResponse no longer marked closed when the connection
authorSerhiy Storchaka <storchaka@gmail.com>
Wed, 6 Feb 2013 08:37:19 +0000 (10:37 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Wed, 6 Feb 2013 08:37:19 +0000 (10:37 +0200)
is automatically closed.

1  2 
Lib/http/client.py
Lib/test/test_httplib.py
Misc/NEWS

Simple merge
index be2d77160c61c3fd5cde8d6d8e3cd13e02b7764d,db123dcb56f7b4a4dd83f47a7735d48a9b51d0e1..a2f141ec5e8495146b3c026f16aeef1d6e771f87
@@@ -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 6bb65264b635f106ddd74e968cd209ef363312f6,b7f121455b9d63771dd0d0d186e884f07eb4e706..f69e7e7a5cc8e2c226be5818e670647fdd83af4f
+++ 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.