Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to iterate over chunks as sent by server. #1805

Closed
ahane opened this issue Apr 10, 2017 · 4 comments
Closed

Unable to iterate over chunks as sent by server. #1805

ahane opened this issue Apr 10, 2017 · 4 comments
Labels

Comments

@ahane
Copy link

ahane commented Apr 10, 2017

Long story short

I am talking to a HTTP server that uses transfer-encoding: chunked to stream records, whith each chunk representing one record.
aiohttp currently offers no API for iterating over the chunks exactly as sent by the server.

Expected behaviour

I would expect the response.content.iter_chunked(n) method to default to the chunking already defined by the server if n=None or a special flag is passed.

See the similar method in the Requests library that shows the desired behaviour.

Actual behaviour

n=None returns an empty bytestring, while n=-1 doesn't return at all.

There is no method to recover the chunking of the server.

@fafhrd91
Copy link
Member

you can use readany, it returns data available in buffer. but right now it is not possible.
would you like to provide PR?

@ahane
Copy link
Author

ahane commented Apr 10, 2017

yes ;) readany does join all chunks in the buffer into one bytestring though
#1806

@fafhrd91
Copy link
Member

fixed by you :)

@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants