summaryrefslogtreecommitdiff
path: root/requests_cache
diff options
context:
space:
mode:
authorDavid Dv Schmidt <david.dv.schmidt@deutschebahn.com>2023-02-02 10:55:51 +0100
committerJordan Cook <jordan.cook.git@proton.me>2023-02-18 15:55:25 -0600
commit1cf227055c16f52796674ad6c88de5cafcee122b (patch)
tree064135d5acdc0630e04d7f8a4049a9b9c12e8eb3 /requests_cache
parent476c873a06b735602d23d9a80261b6ab6ca65ea8 (diff)
downloadrequests-cache-1cf227055c16f52796674ad6c88de5cafcee122b.tar.gz
Don't raise_for_status if status_code of response is in allowable_codes
Diffstat (limited to 'requests_cache')
-rw-r--r--requests_cache/session.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/requests_cache/session.py b/requests_cache/session.py
index c0e2563..c2eaa74 100644
--- a/requests_cache/session.py
+++ b/requests_cache/session.py
@@ -253,7 +253,10 @@ class CacheMixin(MIXIN_BASE):
logger.debug('Stale response; attempting to re-send request')
try:
response = self._send_and_cache(request, actions, cached_response, **kwargs)
- if self.settings.stale_if_error:
+ if (
+ self.settings.stale_if_error
+ and response.status_code not in self.settings.allowable_codes
+ ):
response.raise_for_status()
return response
except Exception: