Name and Version
latest
What is the problem this feature will solve?
AsyncFiles.download() exposes FileDownloadResponse.aiter_bytes(), but the underlying HTTP request appears to buffer the whole response before iteration.
AsyncHTTPClient.request() currently calls:
response = await self._internal_http_client.send(request)
without stream=True.
Because of this, FileDownloadResponse.aiter_bytes() iterates over an already received response body instead of streaming directly from the network.
What is the feature you are proposing to solve the problem?
Motivation
Large file downloads should not require loading the whole body into memory before processing. StatGPT Backend imports channel archives from DIAL storage and currently uses a direct httpx.AsyncClient.stream(...) call to avoid buffering large ZIP files.
Proposed API
Add a streaming download API, for example:
async with async_client.files.stream_download(url) as response:
async for chunk in response.aiter_bytes():
...
Alternatively, download(..., stream=True) could return an async context-managed streaming response.
Requirements
- The response body should not be fully buffered before iteration.
- Response headers should be available before consuming the body.
- The API should safely close the response and connection after consumption.
- Existing non-streaming
download() behavior can remain unchanged.
What alternatives have you considered?
No response
Name and Version
latest
What is the problem this feature will solve?
AsyncFiles.download()exposesFileDownloadResponse.aiter_bytes(), but the underlying HTTP request appears to buffer the whole response before iteration.AsyncHTTPClient.request()currently calls:without
stream=True.Because of this,
FileDownloadResponse.aiter_bytes()iterates over an already received response body instead of streaming directly from the network.What is the feature you are proposing to solve the problem?
Motivation
Large file downloads should not require loading the whole body into memory before processing. StatGPT Backend imports channel archives from DIAL storage and currently uses a direct
httpx.AsyncClient.stream(...)call to avoid buffering large ZIP files.Proposed API
Add a streaming download API, for example:
Alternatively,
download(..., stream=True)could return an async context-managed streaming response.Requirements
download()behavior can remain unchanged.What alternatives have you considered?
No response