Closed simon-liebehenschel closed 3 years ago
aiohttp handles redirect, but aiohttp-client-cache does not when requesting bytes.
Read bytes after redirect, as aiohttp do.
import asyncio from aiohttp_client_cache import CachedSession, SQLiteBackend cache = SQLiteBackend() async def test_stream(): async with CachedSession(cache=cache) as session: response = await session.get("https://file-examples.com/wp-content/uploads/2017/10/file_example_JPG_2500kB.jpg") print("From cache:", response.from_cache) response_bytes = b"" while chunk := await response.content.readany(): print("Chunk:", chunk) response_bytes += chunk print("Complete response body:", response_bytes) async def main(): await cache.clear() await test_stream() await test_stream() if __name__ == "__main__": asyncio.run(main())
It will print:
From cache: False Complete response body: b'' From cache: False Complete response body: b''
I do not know
Looks like the fix for #95 also fixed this one. Thanks!
Fixed. Thank you.
The problem
aiohttp handles redirect, but aiohttp-client-cache does not when requesting bytes.
Expected behavior
Read bytes after redirect, as aiohttp do.
Steps to reproduce the behavior
It will print:
Workarounds
I do not know
Environment