Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
JWCook committed Jun 5, 2023
1 parent f108ce7 commit 127cebf
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions requests_cache/policy/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,17 @@ def _validate_vary(
# Generate a secondary cache key based on Vary for both the cached request and new request.
# If there are redirects, compare the new request against the last request in the chain.
key_kwargs['match_headers'] = [k.strip() for k in vary.split(',')]
vary_request = (
cached_response.history[-1].request
if cached_response.history
else cached_response.request
)

try:
vary_request = (
cached_response.history[-1].request
if cached_response.history
else cached_response.request
)
# Bug with python<=3.8: Somehow history is still dicts, i.e. the cattrs structure hook fails
except AttributeError:
vary_request = CachedResponse.from_response(cached_response.history[-1]).request

vary_cache_key = create_key(vary_request, **key_kwargs)
headers_match = create_key(self._request, **key_kwargs) == vary_cache_key
if not headers_match:
Expand Down

0 comments on commit 127cebf

Please sign in to comment.