def urlopen(self, method, url, body=None, headers=None, retries=None,<EOL>redirect=True, assert_same_host=True, timeout=_Default,<EOL>pool_timeout=None, release_conn=None, **response_kw):
if headers is None:<EOL><INDENT>headers = self.headers<EOL><DEDENT>if not isinstance(retries, Retry):<EOL><INDENT>retries = Retry.from_int(retries, redirect=redirect, default=self.retries)<EOL><DEDENT>if release_conn is None:<EOL><INDENT>release_conn = response_kw.get('<STR_LIT>', True)<EOL><DEDENT>if assert_same_host and not self.is_same_host(url):<EOL><INDENT>raise HostChangedError(self, url, retries)<EOL><DEDENT>conn = None<EOL>if self.scheme == '<STR_LIT:http>':<EOL><INDENT>headers = headers.copy()<EOL>headers.update(self.proxy_headers)<EOL><DEDENT>err = None<EOL>try:<EOL><INDENT>conn = self._get_conn(timeout=pool_timeout)<EOL>httplib_response = self._make_request(conn, method, url,<EOL>timeout=timeout,<EOL>body=body, headers=headers)<EOL>response_conn = not release_conn and conn<EOL>response = HTTPResponse.from_httplib(httplib_response,<EOL>pool=self,<EOL>connection=response_conn,<EOL>**response_kw)<EOL><DEDENT>except Empty:<EOL><INDENT>raise EmptyPoolError(self, "<STR_LIT>")<EOL><DEDENT>except (BaseSSLError, CertificateError) as e:<EOL><INDENT>if conn:<EOL><INDENT>conn.close()<EOL>conn = None<EOL><DEDENT>raise SSLError(e)<EOL><DEDENT>except (TimeoutError, HTTPException, SocketError, ConnectionError) as e:<EOL><INDENT>if conn:<EOL><INDENT>conn.close()<EOL>conn = None<EOL><DEDENT>stacktrace = sys.exc_info()[<NUM_LIT:2>]<EOL>if isinstance(e, SocketError) and self.proxy:<EOL><INDENT>e = ProxyError('<STR_LIT>', e)<EOL><DEDENT>elif isinstance(e, (SocketError, HTTPException)):<EOL><INDENT>e = ProtocolError('<STR_LIT>', e)<EOL><DEDENT>retries = retries.increment(method, url, error=e,<EOL>_pool=self, _stacktrace=stacktrace)<EOL>retries.sleep()<EOL>err = e<EOL><DEDENT>finally:<EOL><INDENT>if release_conn:<EOL><INDENT>self._put_conn(conn)<EOL><DEDENT><DEDENT>if not conn:<EOL><INDENT>log.warning("<STR_LIT>"<EOL>"<STR_LIT>" % (retries, err, url))<EOL>return self.urlopen(method, url, body, headers, retries,<EOL>redirect, assert_same_host,<EOL>timeout=timeout, pool_timeout=pool_timeout,<EOL>release_conn=release_conn, **response_kw)<EOL><DEDENT>redirect_location = redirect and response.get_redirect_location()<EOL>if redirect_location:<EOL><INDENT>if response.status == <NUM_LIT>:<EOL><INDENT>method = '<STR_LIT:GET>'<EOL><DEDENT>try:<EOL><INDENT>retries = retries.increment(method, url, response=response, _pool=self)<EOL><DEDENT>except MaxRetryError:<EOL><INDENT>if retries.raise_on_redirect:<EOL><INDENT>raise<EOL><DEDENT>return response<EOL><DEDENT>log.info("<STR_LIT>" % (url, redirect_location))<EOL>return self.urlopen(method, redirect_location, body, headers,<EOL>retries=retries, redirect=redirect,<EOL>assert_same_host=assert_same_host,<EOL>timeout=timeout, pool_timeout=pool_timeout,<EOL>release_conn=release_conn, **response_kw)<EOL><DEDENT>if retries.is_forced_retry(method, status_code=response.status):<EOL><INDENT>retries = retries.increment(method, url, response=response, _pool=self)<EOL>retries.sleep()<EOL>log.info("<STR_LIT>" % url)<EOL>return self.urlopen(method, url, body, headers,<EOL>retries=retries, redirect=redirect,<EOL>assert_same_host=assert_same_host,<EOL>timeout=timeout, pool_timeout=pool_timeout,<EOL>release_conn=release_conn, **response_kw)<EOL><DEDENT>return response<EOL>
Get a connection from the pool and perform an HTTP request. This is the
lowest level call for making a request, so you'll need to specify all
the raw details.

.. note::

   More commonly, it's appropriate to use a convenience method provided
   by :class:`.RequestMethods`, such as :meth:`request`.

.. note::

   `release_conn` will only behave as expected if
   `preload_content=False` because we want to make
   `preload_content=False` the default behaviour someday soon without
   breaking backwards compatibility.

:param method:
    HTTP request method (such as GET, POST, PUT, etc.)

:param body:
    Data to send in the request body (useful for creating
    POST requests, see HTTPConnectionPool.post_url for
    more convenience).

:param headers:
    Dictionary of custom headers to send, such as User-Agent,
    If-None-Match, etc. If None, pool headers are used. If provided,
    these headers completely replace any pool-specific headers.

:param retries:
    Configure the number of retries to allow before raising a
    :class:`~urllib3.exceptions.MaxRetryError` exception.

    Pass ``None`` to retry until you receive a response. Pass a
    :class:`~urllib3.util.retry.Retry` object for fine-grained control
    over different types of retries.
    Pass an integer number to retry connection errors that many times,
    but no other types of errors. Pass zero to never retry.

    If ``False``, then retries are disabled and any exception is raised
    immediately. Also, instead of raising a MaxRetryError on redirects,
    the redirect response will be returned.

:type retries: :class:`~urllib3.util.retry.Retry`, False, or an int.

:param redirect:
    If True, automatically handle redirects (status codes 301, 302,
    303, 307, 308). Each redirect counts as a retry. Disabling retries
    will disable redirect, too.

:param assert_same_host:
    If ``True``, will make sure that the host of the pool requests is
    consistent else will raise HostChangedError. When False, you can
    use the pool on an HTTP proxy and request foreign hosts.

:param timeout:
    If specified, overrides the default timeout for this one
    request. It may be a float (in seconds) or an instance of
    :class:`urllib3.util.Timeout`.

:param pool_timeout:
    If set and the pool is set to block=True, then this method will
    block for ``pool_timeout`` seconds and raise EmptyPoolError if no
    connection is available within the time period.

:param release_conn:
    If False, then the urlopen call will not release the connection
    back into the pool once a response is received (but will release if
    you read the entire contents of the response such as when
    `preload_content=True`). This is useful if you're not preloading
    the response's content immediately. You will need to call
    ``r.release_conn()`` on the response ``r`` to return the connection
    back into the pool. If None, it takes the value of
    ``response_kw.get('preload_content', True)``.

:param \**response_kw:
    Additional parameters are passed to
    :meth:`urllib3.response.HTTPResponse.from_httplib`