Skip to content

Instantly share code, notes, and snippets.

Last active Nov 26, 2019
What would you like to do?
from byoio import receive_until, receive_some
async def decode_chunked(stream, buf):
while True:
header = await receive_until(stream, buf, b"\r\n")
to_read = int(header.strip()) # FIXME: proper validation
if to_read == 0:
# FIXME: read trailers
while to_read > 0:
piece = await receive_some(stream, buf, to_read)
to_read -= len(piece)
yield piece
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment