diff options
author | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-06-24 07:53:05 -0500 |
---|---|---|
committer | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-06-24 07:56:25 -0500 |
commit | 6ee5a944fa9bc70ac10a0b49e39abce9f7d8b5f4 (patch) | |
tree | 153ce7764f703df6253348e8d35af73541a3d63b | |
parent | d56309aacaaacc51c6bff27892a644185852594e (diff) | |
download | urllib3-bug/907.tar.gz |
Fix chunked transfer-encoding with preload_contentbug/907
When we implemented our own chunked transfer-encoding logic, we broke
the use case (that we did not anticipate) of people not specifying
preload_content=False to stream their data. This provides a fix, sans
tests, for that use case.
Closes gh-907
-rw-r--r-- | urllib3/response.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/urllib3/response.py b/urllib3/response.py index 55679032..a896cb7f 100644 --- a/urllib3/response.py +++ b/urllib3/response.py @@ -133,7 +133,7 @@ class HTTPResponse(io.IOBase): self.chunked = True # If requested, preload the body. - if preload_content and not self._body: + if preload_content and not (self._body or self.chunked): self._body = self.read(decode_content=decode_content) def get_redirect_location(self): @@ -485,6 +485,8 @@ class HTTPResponse(io.IOBase): If True, will attempt to decode the body based on the 'content-encoding' header. """ + if self._body: + return self._init_decoder() # FIXME: Rewrite this method and make it a class with a better structured logic. if not self.chunked: |