Closed rkfcccccc closed 2 years ago
Thanks for reporting this, I'll get that fixed soon.
I looked into this a bit more. It looks like the cached response does keep cookies, but CachedSession._request()
is missing the extra step to set the session cookies after retrieving the cached response. That part is an easy fix.
However, that particular httpbin endpoint returns a redirect (which aiohttp automatically follows), so cookies aren't actually set on response.cookies
, but rather in redirect history (response.history[0].cookies
). This makes things a bit complicated, since aiohttp-client-cache
optimizes redirects by pointing directly to the final redirect response instead of following the full redirect chain like aiohttp
does. This is also fixable, but a little bit more work.
@rkfcccccc Sorry for the delay, but it looks like I actually fixed this with #101 and didn't realize it. I thought I had only partially fixed the issue, and I was totally stumped as to why it still wasn't working with redirect cookies. I just revisited this to test it again, and... it's working. 🤷
So I have no idea what was going on earlier, but I added tests to cover this, and the fix is now in v0.6. Give that a try and let me know if you have any more problems.
The problem
Cached response doesn't keep the cookies.
Expected behavior
It should
Steps to reproduce the behavior
Environment
0.5.1
3.9.6
MacOS