Merge pull request #4206 from jvanasco/feature-redirects

some docs on request redirect detection
This commit is contained in:
Cory Benfield
2017-07-26 20:57:22 +01:00
committed by GitHub
+6
View File
@@ -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