summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/http/client.py2
-rw-r--r--Lib/test/test_httplib.py3
2 files changed, 4 insertions, 1 deletions
diff --git a/Lib/http/client.py b/Lib/http/client.py
index cc452e2..e05c84d 100644
--- a/Lib/http/client.py
+++ b/Lib/http/client.py
@@ -544,7 +544,7 @@ class HTTPResponse(io.RawIOBase):
# connection, and the user is reading more bytes than will be provided
# (for example, reading in 1k chunks)
n = self.fp.readinto(b)
- if not n:
+ if not n and b:
# Ideally, we would raise IncompleteRead if the content-length
# wasn't satisfied, but it might break compatibility.
self._close_conn()
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
index f3c27c2..4410a93 100644
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -162,6 +162,9 @@ class BasicTest(TestCase):
sock = FakeSocket(body)
resp = client.HTTPResponse(sock)
resp.begin()
+ self.assertEqual(resp.read(0), b'') # Issue #20007
+ self.assertFalse(resp.isclosed())
+ self.assertFalse(resp.closed)
self.assertEqual(resp.read(), b"Text")
self.assertTrue(resp.isclosed())
self.assertFalse(resp.closed)