get_redirect_target() — requests Function Reference
Architecture documentation for the get_redirect_target() function in sessions.py from the requests codebase.
Entity Profile
Dependency Diagram
graph TD 45e5de53_d23e_6c69_97ea_d5a29d1fcd7b["get_redirect_target()"] 29cd946c_8c0d_e37c_acb9_dfb2b83bf42b["SessionRedirectMixin"] 45e5de53_d23e_6c69_97ea_d5a29d1fcd7b -->|defined in| 29cd946c_8c0d_e37c_acb9_dfb2b83bf42b cbf6862f_d124_817f_3342_f1142c276f25["resolve_redirects()"] cbf6862f_d124_817f_3342_f1142c276f25 -->|calls| 45e5de53_d23e_6c69_97ea_d5a29d1fcd7b 0ab29509_59a1_1f68_fae2_146376240019["to_native_string()"] 45e5de53_d23e_6c69_97ea_d5a29d1fcd7b -->|calls| 0ab29509_59a1_1f68_fae2_146376240019 style 45e5de53_d23e_6c69_97ea_d5a29d1fcd7b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/requests/sessions.py lines 108–126
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
# in latin1, but empirical evidence suggests that latin1 is very
# rarely used with non-ASCII characters in HTTP headers.
# It is more likely to get UTF8 header rather than latin1.
# This causes incorrect handling of UTF8 encoded location headers.
# To solve this, we re-encode the location in latin1.
location = location.encode("latin1")
return to_native_string(location, "utf8")
return None
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does get_redirect_target() do?
get_redirect_target() is a function in the requests codebase, defined in src/requests/sessions.py.
Where is get_redirect_target() defined?
get_redirect_target() is defined in src/requests/sessions.py at line 108.
What does get_redirect_target() call?
get_redirect_target() calls 1 function(s): to_native_string.
What calls get_redirect_target()?
get_redirect_target() is called by 1 function(s): resolve_redirects.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free