mirror of https://github.com/python/cpython.git
Issue #20007: HTTPResponse.read(0) no more prematurely closes connection.
Original patch by Simon Sapin.
This commit is contained in:
commit
cac05e2e90
|
@ -538,7 +538,7 @@ def readinto(self, b):
|
||||||
# connection, and the user is reading more bytes than will be provided
|
# connection, and the user is reading more bytes than will be provided
|
||||||
# (for example, reading in 1k chunks)
|
# (for example, reading in 1k chunks)
|
||||||
n = self.fp.readinto(b)
|
n = self.fp.readinto(b)
|
||||||
if not n:
|
if not n and b:
|
||||||
# Ideally, we would raise IncompleteRead if the content-length
|
# Ideally, we would raise IncompleteRead if the content-length
|
||||||
# wasn't satisfied, but it might break compatibility.
|
# wasn't satisfied, but it might break compatibility.
|
||||||
self._close_conn()
|
self._close_conn()
|
||||||
|
|
|
@ -164,6 +164,9 @@ def test_status_lines(self):
|
||||||
sock = FakeSocket(body)
|
sock = FakeSocket(body)
|
||||||
resp = client.HTTPResponse(sock)
|
resp = client.HTTPResponse(sock)
|
||||||
resp.begin()
|
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.assertEqual(resp.read(), b"Text")
|
||||||
self.assertTrue(resp.isclosed())
|
self.assertTrue(resp.isclosed())
|
||||||
self.assertFalse(resp.closed)
|
self.assertFalse(resp.closed)
|
||||||
|
|
|
@ -1136,6 +1136,7 @@ Adrian Sampson
|
||||||
James Sanders
|
James Sanders
|
||||||
Ilya Sandler
|
Ilya Sandler
|
||||||
Rafael Santos
|
Rafael Santos
|
||||||
|
Simon Sapin
|
||||||
Mark Sapiro
|
Mark Sapiro
|
||||||
Ty Sarna
|
Ty Sarna
|
||||||
Hugh Sasse
|
Hugh Sasse
|
||||||
|
|
|
@ -44,6 +44,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #20007: HTTPResponse.read(0) no more prematurely closes connection.
|
||||||
|
Original patch by Simon Sapin.
|
||||||
|
|
||||||
- Issue #19946: multiprocessing now uses runpy to initialize __main__ in
|
- Issue #19946: multiprocessing now uses runpy to initialize __main__ in
|
||||||
child processes when necessary, allowing it to correctly handle scripts
|
child processes when necessary, allowing it to correctly handle scripts
|
||||||
without suffixes and submodules that use explicit relative imports or
|
without suffixes and submodules that use explicit relative imports or
|
||||||
|
|
Loading…
Reference in New Issue