#NEWLINE# def urlopen( self , method , url , body = None , headers = None , retries = 3 , redirect = True , assert_same_host = True , timeout = _Default , pool_timeout = None , release_conn = None , **response_kw ) : #NEWLINE# #INDENT# "\n        Get a connection from the pool and perform an HTTP request. This is the\n        lowest level call for making a request, so you'll need to specify all\n        the raw details.\n\n        .. note::\n\n           More commonly, it's appropriate to use a convenience method provided\n           by :class:`.RequestMethods`, such as :meth:`.request`.\n\n        .. note::\n\n           `release_conn` will only behave as expected if\n           `preload_content=False` because we want to make\n           `preload_content=False` the default behaviour someday soon without\n           breaking backwards compatibility.\n\n        :param method:\n            HTTP request method (such as GET, POST, PUT, etc.)\n\n        :param body:\n            Data to send in the request body (useful for creating\n            POST requests, see HTTPConnectionPool.post_url for\n            more convenience).\n\n        :param headers:\n            Dictionary of custom headers to send, such as User-Agent,\n            If-None-Match, etc. If None, pool headers are used. If provided,\n            these headers completely replace any pool-specific headers.\n\n        :param retries:\n            Number of retries to allow before raising a MaxRetryError exception.\n\n        :param redirect:\n            Automatically handle redirects (status codes 301, 302, 303, 307),\n            each redirect counts as a retry.\n\n        :param assert_same_host:\n            If ``True``, will make sure that the host of the pool requests is\n            consistent else will raise HostChangedError. When False, you can\n            use the pool on an HTTP proxy and request foreign hosts.\n\n        :param timeout:\n            If specified, overrides the default timeout for this one request.\n\n        :param pool_timeout:\n            If set and the pool is set to block=True, then this method will\n            block for ``pool_timeout`` seconds and raise EmptyPoolError if no\n            connection is available within the time period.\n\n        :param release_conn:\n            If False, then the urlopen call will not release the connection\n            back into the pool once a response is received (but will release if\n            you read the entire contents of the response such as when\n            `preload_content=True`). This is useful if you're not preloading\n            the response's content immediately. You will need to call\n            ``r.release_conn()`` on the response ``r`` to return the connection\n            back into the pool. If None, it takes the value of\n            ``response_kw.get('preload_content', True)``.\n\n        :param \\**response_kw:\n            Additional parameters are passed to\n            :meth:`urllib3.response.HTTPResponse.from_httplib`\n        " #NEWLINE# if ( headers is None ) : #NEWLINE# #INDENT# headers = self . headers #NEWLINE# #UNINDENT# if ( retries < 0 ) : #NEWLINE# #INDENT# raise MaxRetryError ( self , url ) #NEWLINE# #UNINDENT# if ( timeout is _Default ) : #NEWLINE# #INDENT# timeout = self . timeout #NEWLINE# #UNINDENT# if ( release_conn is None ) : #NEWLINE# #INDENT# release_conn = response_kw . get ( 'preload_content' , True ) #NEWLINE# #UNINDENT# if ( assert_same_host and ( not self . is_same_host ( url ) ) ) : #NEWLINE# #INDENT# host = ( '%s://%s' % ( self . scheme , self . host ) ) #NEWLINE# if self . port : #NEWLINE# #INDENT# host = ( '%s:%d' % ( host , self . port ) ) #NEWLINE# #UNINDENT# raise HostChangedError ( self , url , ( retries - 1 ) ) #NEWLINE# #UNINDENT# conn = None #NEWLINE# try : #NEWLINE# #INDENT# conn = self . _get_conn ( timeout = pool_timeout ) #NEWLINE# httplib_response = self . _make_request ( conn , method , url , timeout = timeout , body = body , headers = headers ) #NEWLINE# response_conn = ( ( not release_conn ) and conn ) #NEWLINE# response = HTTPResponse . from_httplib ( httplib_response , pool = self , connection = response_conn , ** response_kw ) #NEWLINE# #UNINDENT# except Empty as e : #NEWLINE# #INDENT# raise TimeoutError ( self , ( 'Request timed out. (pool_timeout=%s)' % pool_timeout ) ) #NEWLINE# #UNINDENT# except SocketTimeout as e : #NEWLINE# #INDENT# raise TimeoutError ( self , ( 'Request timed out. (timeout=%s)' % timeout ) ) #NEWLINE# #UNINDENT# except BaseSSLError as e : #NEWLINE# #INDENT# raise SSLError ( e ) #NEWLINE# #UNINDENT# except CertificateError as e : #NEWLINE# #INDENT# raise SSLError ( e ) #NEWLINE# #UNINDENT# except ( HTTPException , SocketError ) as e : #NEWLINE# #INDENT# conn = None #NEWLINE# err = e #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# if ( conn and release_conn ) : #NEWLINE# #INDENT# self . _put_conn ( conn ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not conn ) : #NEWLINE# #INDENT# log . warn ( ( "Retrying (%d attempts remain) after connection broken by '%r': %s" % ( retries , err , url ) ) ) #NEWLINE# return self . urlopen ( method , url , body , headers , ( retries - 1 ) , redirect , assert_same_host ) #NEWLINE# #UNINDENT# redirect_location = ( redirect and response . get_redirect_location ( ) ) #NEWLINE# if redirect_location : #NEWLINE# #INDENT# log . info ( ( 'Redirecting %s -> %s' % ( url , redirect_location ) ) ) #NEWLINE# return self . urlopen ( method , redirect_location , body , headers , ( retries - 1 ) , redirect , assert_same_host ) #NEWLINE# #UNINDENT# return response