python-hyper / hyper

HTTP/2 for Python.
http://hyper.rtfd.org/en/latest/
MIT License
1.05k stars 191 forks source link

how to iterate over read(amt,decode_content=True)? #373

Closed deshmukhrajvardhan closed 6 years ago

deshmukhrajvardhan commented 6 years ago

Hi all, i wanted to read the response in a block of data units. So, is there a way to use the read(DATA_BLOCK_SIZE) iteratively till all the response data is read?

(Just like the 'iter_content(CHUNK_SIZE)' in the requests library)

Thanks, Raj

sigmavirus24 commented 6 years ago

Perhaps

chunk = read()
while chunk:
    # do stuff
    chunk = read()
Lukasa commented 6 years ago

Yeah, call read repeatedly.

deshmukhrajvardhan commented 6 years ago

Thanks https://github.com/sigmavirus24 and https://github.com/Lukasa

It works fine.