File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -538,7 +538,7 @@ def readinto(self, b):
538538 # connection, and the user is reading more bytes than will be provided
539539 # (for example, reading in 1k chunks)
540540 n = self .fp .readinto (b )
541- if not n :
541+ if not n and b :
542542 # Ideally, we would raise IncompleteRead if the content-length
543543 # wasn't satisfied, but it might break compatibility.
544544 self ._close_conn ()
Original file line number Diff line number Diff line change @@ -164,6 +164,9 @@ def test_status_lines(self):
164164 sock = FakeSocket (body )
165165 resp = client .HTTPResponse (sock )
166166 resp .begin ()
167+ self .assertEqual (resp .read (0 ), b'' ) # Issue #20007
168+ self .assertFalse (resp .isclosed ())
169+ self .assertFalse (resp .closed )
167170 self .assertEqual (resp .read (), b"Text" )
168171 self .assertTrue (resp .isclosed ())
169172 self .assertFalse (resp .closed )
Original file line number Diff line number Diff line change @@ -1136,6 +1136,7 @@ Adrian Sampson
11361136James Sanders
11371137Ilya Sandler
11381138Rafael Santos
1139+ Simon Sapin
11391140Mark Sapiro
11401141Ty Sarna
11411142Hugh Sasse
Original file line number Diff line number Diff line change @@ -44,6 +44,9 @@ Core and Builtins
4444Library
4545-------
4646
47+ - Issue #20007: HTTPResponse.read(0) no more prematurely closes connection.
48+ Original patch by Simon Sapin.
49+
4750- Issue #19946: multiprocessing now uses runpy to initialize __main__ in
4851 child processes when necessary, allowing it to correctly handle scripts
4952 without suffixes and submodules that use explicit relative imports or
You can’t perform that action at this time.
0 commit comments