Kaydet (Commit) def9d2a1 authored tarafından Jeremy Hylton's avatar Jeremy Hylton

Fix for SF bug 988120 via patch 1061941.

If read() returned less than the number of bytes request, the full amount was subtracted from length instead of the actually read amount.
üst f164322f
...@@ -457,10 +457,11 @@ class HTTPResponse: ...@@ -457,10 +457,11 @@ class HTTPResponse:
if amt is None: if amt is None:
# unbounded read # unbounded read
if self.will_close: if self.length is None:
s = self.fp.read() s = self.fp.read()
else: else:
s = self._safe_read(self.length) s = self._safe_read(self.length)
self.length = 0
self.close() # we read everything self.close() # we read everything
return s return s
...@@ -468,12 +469,13 @@ class HTTPResponse: ...@@ -468,12 +469,13 @@ class HTTPResponse:
if amt > self.length: if amt > self.length:
# clip the read to the "end of response" # clip the read to the "end of response"
amt = self.length amt = self.length
self.length -= amt
# we do not use _safe_read() here because this may be a .will_close # we do not use _safe_read() here because this may be a .will_close
# 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)
s = self.fp.read(amt) s = self.fp.read(amt)
if self.length is not None:
self.length -= len(s)
return s return s
......
...@@ -302,6 +302,7 @@ Jiba ...@@ -302,6 +302,7 @@ Jiba
Orjan Johansen Orjan Johansen
Simon Johnston Simon Johnston
Richard Jones Richard Jones
Irmen de Jong
Lucas de Jonge Lucas de Jonge
Jens B. Jorgensen Jens B. Jorgensen
John Jorgensen John Jorgensen
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment