From 27c83f71770a2a64d56b7d53f9cc67f53cf70ccd Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Sun, 7 Sep 2014 12:02:23 -0500 Subject: [PATCH] Fix #2207 @Lukasa wrote the fix in #2207 --- requests/sessions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requests/sessions.py b/requests/sessions.py index 334db58..023edfb 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -134,8 +134,8 @@ class SessionRedirectMixin(object): url = requote_uri(url) prepared_request.url = to_native_string(url) - # cache the url - if resp.is_permanent_redirect: + # Cache the url, unless it redirects to itself. + if resp.is_permanent_redirect and req.url != prepared_request.url: self.redirect_cache[req.url] = prepared_request.url # http://tools.ietf.org/html/rfc7231#section-6.4.4 -- 2.34.1