On 01Jul2015 21:51, Peter Otten <[email protected]> wrote:
[email protected] wrote:
But how to read chunks?
Instead of
data = response.read() # a `bytes` object
out_file.write(data)
use a loop:
CHUNKSIZE = 16*1024 # for example
while True:
data = response.read(CHUNKSIZE)
if not data:
break
out_file.write(data)
It might be worth noting here that Peter's "chunk" is just an arbitrary amount
of data to read in a unit. I'm only mentioning this because the HTTP
specification has a "chunked-encoding" used to return binary files, and we are
not talking about _those_ chunks.
Cheers,
Cameron Simpson <[email protected]>
Life is uncertain. Eat dessert first. - Jim Blandy
--
https://mail.python.org/mailman/listinfo/python-list