From 667896c557718114fcb1c365f29e5d04413bff84 Mon Sep 17 00:00:00 2001 From: jonathan vanasco Date: Wed, 26 Jul 2017 15:29:32 -0400 Subject: [PATCH] some docs on request redirect detection --- requests/sessions.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/requests/sessions.py b/requests/sessions.py index 8c06448e..6570e733 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -97,6 +97,12 @@ class SessionRedirectMixin(object): def get_redirect_target(self, resp): """Receives a Response. Returns a redirect URI or ``None``""" + # Due to the nature of how requests processes redirects this method will + # be called at least once upon the original response and at least twice + # on each subsequent redirect response (if any). + # If a custom mixin is used to handle this logic, it may be advantageous + # to cache the redirect location onto the response object as a private + # attribute. if resp.is_redirect: location = resp.headers['location'] # Currently the underlying http module on py3 decode headers