parameters: (self, old_url, new_url)
return_statement: return changed_port or changed_scheme
docstring: Decide whether Authorization header should be removed when redirecting
docstring_summary: Decide whether Authorization header should be removed when redirecting
docstring_tokens: Decide whether Authorization header should be removed when redirecting
function: def should_strip_auth(self, old_url, new_url):
  
          """Decide whether Authorization header should be removed when redirecting"""
  
          old_parsed = urlparse(old_url)
  
          new_parsed = urlparse(new_url)
  
          if old_parsed.hostname != new_parsed.hostname:
  
              return True
  
          # Special case: allow http -> https redirect when using the standard
  
          # ports. This isn't specified by RFC 7235, but is kept to avoid
  
          # breaking backwards compatibility with older versions of requests
  
          # that allowed any redirects on the same host.
  
          if (old_parsed.scheme == 'http' and old_parsed.port in (80, None)
  
                  and new_parsed.scheme == 'https' and new_parsed.port in (443, None)):
  
              return False
  
  
  
          # Handle default port usage corresponding to scheme.
  
          changed_port = old_parsed.port != new_parsed.port
  
          changed_scheme = old_parsed.scheme != new_parsed.scheme
  
          default_port = (DEFAULT_PORTS.get(old_parsed.scheme, None), None)
  
          if (not changed_scheme and old_parsed.port in default_port
  
                  and new_parsed.port in default_port):
  
              return False
  
  
  
          # Standard case: root URI must match
  
          return changed_port or changed_scheme
function_tokens: def should_strip_auth ( self , old_url , new_url ) : old_parsed = urlparse ( old_url ) new_parsed = urlparse ( new_url ) if old_parsed . hostname != new_parsed . hostname : return True # Special case: allow http -> https redirect when using the standard # ports. This isn't specified by RFC 7235, but is kept to avoid # breaking backwards compatibility with older versions of requests # that allowed any redirects on the same host. if ( old_parsed . scheme == 'http' and old_parsed . port in ( 80 , None ) and new_parsed . scheme == 'https' and new_parsed . port in ( 443 , None ) ) : return False # Handle default port usage corresponding to scheme. changed_port = old_parsed . port != new_parsed . port changed_scheme = old_parsed . scheme != new_parsed . scheme default_port = ( DEFAULT_PORTS . get ( old_parsed . scheme , None ) , None ) if ( not changed_scheme and old_parsed . port in default_port and new_parsed . port in default_port ) : return False # Standard case: root URI must match return changed_port or changed_scheme