0{Y# @sddlZyddlmZWn"ek rDddlmZYnXddlmZddlmZm Z ddlm Z ddl m Z ddl mZd d d gZied 6e d 6ZejeZdZGdd d e ZGdd d eZdd ZdS)N)urljoin)RecentlyUsedContainer)HTTPConnectionPoolHTTPSConnectionPool)port_by_scheme)RequestMethods) parse_url PoolManager ProxyManagerproxy_from_urlhttphttpskey_file cert_file cert_reqsca_certs ssl_versionc@sseZdZdZdZddddZddZdd Zdd d d Zd dZ dddZ dS)r a& Allows for arbitrary requests while transparently keeping track of necessary connection pools for you. :param num_pools: Number of connection pools to cache before discarding the least recently used pool. :param headers: Headers to include with all requests, unless other headers are given explicitly. :param \**connection_pool_kw: Additional parameters are used to create fresh :class:`urllib3.connectionpool.ConnectionPool` instances. Example: :: >>> manager = PoolManager(num_pools=2) >>> r = manager.request('GET', 'http://google.com/') >>> r = manager.request('GET', 'http://google.com/mail') >>> r = manager.request('GET', 'http://yahoo.com/') >>> len(manager.pools) 2 N cKs8tj||||_t|ddd|_dS)N dispose_funccSs |jS)N)close)prL/tmp/pip-ok8sy_ze-build/pip/_vendor/requests/packages/urllib3/poolmanager.pyEsz&PoolManager.__init__..)r__init__connection_pool_kwrpools)self num_poolsheadersrrrrrAs  zPoolManager.__init__cCsbt|}|j}|dkrR|jj}x!tD]}|j|dq5Wn||||S)a Create a new :class:`ConnectionPool` based on host, port and scheme. This method is used to actually create the connection pools handed out by :meth:`connection_from_url` and companion methods. It is intended to be overridden for customization. r N)pool_classes_by_schemercopy SSL_KEYWORDSpop)rschemehostportpool_clskwargskwrrr _new_poolGs    zPoolManager._new_poolcCs|jjdS)z Empty our store of pools and direct them all to close. This will not affect in-flight connections, but they will not be re-used after completion. N)rclear)rrrrr,XszPoolManager.clearr c Cs|p d}|p!tj|d}|||f}|jjC|jj|}|r\|S|j|||}||j| %sretriesr)r r2r&r'r%r proxyurlopen request_uriget_redirect_locationrstatusloginfor.) rmethodr3r7r*r4connresponseredirect_locationrrrr<s& $     zPoolManager.urlopen) __name__ __module__ __qualname____doc__r;rr+r,r2r5r<rrrrr #s    csmeZdZdZdddfddZddfddZdd d Zd fd d ZS)r aw Behaves just like :class:`PoolManager`, but sends all requests through the defined proxy, using the CONNECT method for HTTPS URLs. :param proxy_url: The URL of the proxy to be used. :param proxy_headers: A dictionary contaning headers that will be sent to the proxy. In case of HTTP they are being sent with each request, while in the HTTPS/CONNECT case they are sent only once. Could be used for proxy authentication. Example: >>> proxy = urllib3.ProxyManager('http://localhost:3128/') >>> r1 = proxy.request('GET', 'http://google.com/') >>> r2 = proxy.request('GET', 'http://httpbin.org/') >>> len(proxy.pools) 1 >>> r3 = proxy.request('GET', 'https://httpbin.org/') >>> r4 = proxy.request('GET', 'https://twitter.com/') >>> len(proxy.pools) 3 rNc st|tr.d|j|j|jf}nt|}|jsmtj|jd}|jd|}n||_ |pi|_ |j jd kst d|j j|j |d<|j |ds&   S