You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow setting chunk_size for Response.iter_bytes() etc... #394
Requests allowed setting chunk_size within .iter_content() which is currently not an option for our alternatives .stream() and .stream_text().
For .stream_text() we should go the extra step and fix the issue that users sometimes run into when using this feature and use chunk-size for measuring the decoded text, not the raw bytes.
A good first pass onto this would be to change the decoder interface slightly, so that instead of eg. yeilding a byte chunk, they yield a list of byte chunks.
On the first refactoring pass, we don't need to actually change the internal implmentation much - the decoders can just always yield a list with a single item.
We'd then be able to add a chunk_size argument to the decoders, which would return 0, 1, or many properly-sized chunks on each yield.
changed the title [-]Allow setting chunk_size for Response.stream() and Response.stream_text()[/-][+]Allow setting chunk_size for Response.aiter_*()[/+]on Dec 21, 2019
Hi @b0g3r! I think this is still something we’d like to have, and given discussions in python-gitlab/python-gitlab#1036 it seems like some folks would like to see it too. :)
Ways to move forward would be:
Propose an API for this, with context on the existing API on Requests
Investigate implementation details (ie how are we going to split chunks: buffering, other? Looking at how Requests/urllib3 do this can help)
@b0g3r Careful that we're in a sort of transition state w.r.t. urllib3 usage due to #804 (we'll soon use our own sync implementation, though keeping urllib3 as an option). Due to this I wouldn't advise relying on any existing urllib3 functionality — also because we'd want to provide chunk sizing on the async layer too, and it'd be odd to have a different implementation on both sides.
I think we want to look at controlling the chunk size directly from response.iter_bytes()/response.aiter_bytes(), instead…
I'd start with that as a foundational pull request, which will then make the remaining work much easier. (Adding chunk sizes to the decoder interface, and through to the response methods.)
Would be good to have chunk_size=None option so that httpx can return chunks at the HTTP chunk boundaries as per the requests library - this is useful for apps that require timely delivery.
changed the title [-]Allow setting chunk_size for Response.aiter_*()[/-][+]Allow setting chunk_size for `Response.iter_bytes()` etc...[/+]on Aug 7, 2020
changed the title [-]Allow setting chunk_size for `Response.iter_bytes()` etc...[/-][+]Allow setting `chunk_size` for `Response.iter_bytes()` etc...[/+]on Aug 7, 2020
Activity
lovelydinosaur commentedon Sep 27, 2019
I seem to remeber this playing into some primitives around streaming bytes vs text that we never ended up digging into?
lovelydinosaur commentedon Dec 20, 2019
A good first pass onto this would be to change the decoder interface slightly, so that instead of eg. yeilding a byte chunk, they yield a list of byte chunks.
On the first refactoring pass, we don't need to actually change the internal implmentation much - the decoders can just always yield a list with a single item.
We'd then be able to add a
chunk_sizeargument to the decoders, which would return 0, 1, or many properly-sized chunks on each yield.[-]Allow setting chunk_size for Response.stream() and Response.stream_text()[/-][+]Allow setting chunk_size for Response.aiter_*()[/+]florimondmanca commentedon Dec 21, 2019
Updated the issue title to reflect the current
Response.aiter_*API :-) (see #610).b0g3r commentedon Mar 12, 2020
How could I help with this issue?
florimondmanca commentedon Mar 12, 2020
Hi @b0g3r! I think this is still something we’d like to have, and given discussions in python-gitlab/python-gitlab#1036 it seems like some folks would like to see it too. :)
Ways to move forward would be:
b0g3r commentedon Mar 13, 2020
Do I understand correctly that we will need to forward chunk_size here?
httpx/httpx/_dispatch/urllib3.py
Lines 112 to 115 in a82adcc
florimondmanca commentedon Mar 13, 2020
@b0g3r Careful that we're in a sort of transition state w.r.t. urllib3 usage due to #804 (we'll soon use our own sync implementation, though keeping urllib3 as an option). Due to this I wouldn't advise relying on any existing urllib3 functionality — also because we'd want to provide chunk sizing on the async layer too, and it'd be odd to have a different implementation on both sides.
I think we want to look at controlling the chunk size directly from
response.iter_bytes()/response.aiter_bytes(), instead…lovelydinosaur commentedon Mar 13, 2020
@b0g3r So, as with comment #394 (comment) - the right place to start with this would be a pull request to https://github.com/encode/httpx/blob/master/httpx/_decoders.py that changes the interface of the decoders, so that they return a list of bytes rather than bytes.
(And correspondingly, changing the places where the response calls the decoder such as
httpx/httpx/_models.py
Line 915 in a82adcc
I'd start with that as a foundational pull request, which will then make the remaining work much easier. (Adding chunk sizes to the decoder interface, and through to the response methods.)
b0g3r commentedon Mar 13, 2020
(a)iter_raw(self, chunk_size=1)
chunk_size=1because requests.Response.iter_content has itlet's use bytestring as buffer
(a)iter_bytes(self, chunk_size=ITER_CHUNK_SIZE)
chunk_size=ITER_CHUNK_SIZE(512) because requests has it 🌚(a)iter_raw(a)iter_text(self, chunk_size=ITER_CHUNK_SIZE)
(a)iter_bytes(a)iter_line(self, chunk_size=ITER_CHUNK_SIZE)
(a)iter_testb0g3r commentedon Mar 13, 2020
@tomchristie As I see
(a)iter_rawdoesn't use any decoder 🤔piersoh commentedon May 21, 2020
Would be good to have
chunk_size=Noneoption so that httpx can return chunks at the HTTP chunk boundaries as per the requests library - this is useful for apps that require timely delivery.1 remaining item
[-]Allow setting chunk_size for Response.aiter_*()[/-][+]Allow setting chunk_size for `Response.iter_bytes()` etc...[/+][-]Allow setting chunk_size for `Response.iter_bytes()` etc...[/-][+]Allow setting `chunk_size` for `Response.iter_bytes()` etc...[/+]Added chunk_size to Response.iter_bytes() and Response.aiter_bytes() (e…
Added chunk_size to Response.iter_bytes() and Response.aiter_bytes() (e…
Added chunk_size to Response.iter_bytes() and Response.aiter_bytes() (e…
When chunk_size=None, Response.(a)iter_bytes returns data as it arriv…
Added chunk_size to Response.iter_bytes() and Response.aiter_bytes() (e…
When chunk_size=None, Response.(a)iter_bytes returns data as it arriv…
Added chunk_size to Response.iter_bytes() and Response.aiter_bytes() (e…
When chunk_size=None, Response.(a)iter_bytes returns data as it arriv…
Added chunk_size to Response.iter_bytes() and Response.aiter_bytes() (e…
When chunk_size=None, Response.(a)iter_bytes returns data as it arriv…