Skip to content

Commit e8b993a

Browse files
Use requests to read chunk data instead of parsing the raw stream
The previous code had a bug in which it assumed that the chunk data had no newlines in it. In 0.9.0 newlines were added to the stream results, which exposed this bug.
1 parent d0985b0 commit e8b993a

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

docker/client.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -233,17 +233,8 @@ def _get_raw_response_socket(self, response):
233233

234234
def _stream_helper(self, response):
235235
"""Generator for data coming from a chunked-encoded HTTP response."""
236-
socket_fp = self._get_raw_response_socket(response)
237-
socket_fp.setblocking(1)
238-
socket = socket_fp.makefile()
239-
while True:
240-
size = int(socket.readline(), 16)
241-
if size <= 0:
242-
break
243-
data = socket.readline()
244-
if not data:
245-
break
246-
yield data
236+
for line in response.iter_lines(chunk_size=32):
237+
yield line
247238

248239
def _multiplexed_buffer_helper(self, response):
249240
"""A generator of multiplexed data blocks read from a buffered

0 commit comments

Comments
 (0)