parameters: (self, method, url, redirect=True, **kw)
return_statement: return self.urlopen(method, redirect_location, **kw)
docstring: Same as :meth:`urllib3.HTTPConnectionPool.urlopen`
  
          with custom cross-host redirect logic and only sends the request-uri
  
          portion of the ``url``.
  
  
  
          The given ``url`` parameter must be absolute, such that an appropriate
  
          :class:`urllib3.connectionpool.ConnectionPool` can be chosen for it.
function: def urlopen(self, method, url, redirect=True, **kw):
  
          """
  
          Same as :meth:`urllib3.HTTPConnectionPool.urlopen`
  
          with custom cross-host redirect logic and only sends the request-uri
  
          portion of the ``url``.
  
  
  
          The given ``url`` parameter must be absolute, such that an appropriate
  
          :class:`urllib3.connectionpool.ConnectionPool` can be chosen for it.
  
          """
  
          u = parse_url(url)
  
          self._validate_proxy_scheme_url_selection(u.scheme)
  
  
  
          conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme)
  
  
  
          kw["assert_same_host"] = False
  
          kw["redirect"] = False
  
  
  
          if "headers" not in kw:
  
              kw["headers"] = self.headers.copy()
  
  
  
          if self._proxy_requires_url_absolute_form(u):
  
              response = conn.urlopen(method, url, **kw)
  
          else:
  
              response = conn.urlopen(method, u.request_uri, **kw)
  
  
  
          redirect_location = redirect and response.get_redirect_location()
  
          if not redirect_location:
  
              return response
  
  
  
          # Support relative URLs for redirecting.
  
          redirect_location = urljoin(url, redirect_location)
  
  
  
          # RFC 7231, Section 6.4.4
  
          if response.status == 303:
  
              method = "GET"
  
  
  
          retries = kw.get("retries")
  
          if not isinstance(retries, Retry):
  
              retries = Retry.from_int(retries, redirect=redirect)
  
  
  
          # Strip headers marked as unsafe to forward to the redirected location.
  
          # Check remove_headers_on_redirect to avoid a potential network call within
  
          # conn.is_same_host() which may use socket.gethostbyname() in the future.
  
          if retries.remove_headers_on_redirect and not conn.is_same_host(
  
              redirect_location
  
          ):
  
              headers = list(six.iterkeys(kw["headers"]))
  
              for header in headers:
  
                  if header.lower() in retries.remove_headers_on_redirect:
  
                      kw["headers"].pop(header, None)
  
  
  
          try:
  
              retries = retries.increment(method, url, response=response, _pool=conn)
  
          except MaxRetryError:
  
              if retries.raise_on_redirect:
  
                  response.drain_conn()
  
                  raise
  
              return response
  
  
  
          kw["retries"] = retries
  
          kw["redirect"] = redirect
  
  
  
          log.info("Redirecting %s -> %s", url, redirect_location)
  
  
  
          response.drain_conn()
  
          return self.urlopen(method, redirect_location, **kw)
function_tokens: def urlopen ( self , method , url , redirect = True , * * kw ) : u = parse_url ( url ) self . _validate_proxy_scheme_url_selection ( u . scheme ) conn = self . connection_from_host ( u . host , port = u . port , scheme = u . scheme ) kw [ "assert_same_host" ] = False kw [ "redirect" ] = False if "headers" not in kw : kw [ "headers" ] = self . headers . copy ( ) if self . _proxy_requires_url_absolute_form ( u ) : response = conn . urlopen ( method , url , * * kw ) else : response = conn . urlopen ( method , u . request_uri , * * kw ) redirect_location = redirect and response . get_redirect_location ( ) if not redirect_location : return response # Support relative URLs for redirecting. redirect_location = urljoin ( url , redirect_location ) # RFC 7231, Section 6.4.4 if response . status == 303 : method = "GET" retries = kw . get ( "retries" ) if not isinstance ( retries , Retry ) : retries = Retry . from_int ( retries , redirect = redirect ) # Strip headers marked as unsafe to forward to the redirected location. # Check remove_headers_on_redirect to avoid a potential network call within # conn.is_same_host() which may use socket.gethostbyname() in the future. if retries . remove_headers_on_redirect and not conn . is_same_host ( redirect_location ) : headers = list ( six . iterkeys ( kw [ "headers" ] ) ) for header in headers : if header . lower ( ) in retries . remove_headers_on_redirect : kw [ "headers" ] . pop ( header , None ) try : retries = retries . increment ( method , url , response = response , _pool = conn ) except MaxRetryError : if retries . raise_on_redirect : response . drain_conn ( ) raise return response kw [ "retries" ] = retries kw [ "redirect" ] = redirect log . info ( "Redirecting %s -> %s" , url , redirect_location ) response . drain_conn ( ) return self . urlopen ( method , redirect_location , * * kw )