σ `8(Zc@@sΨddlmZddlZddlZddlZyddlmZWn!ek rkddlmZnXddl m Z ddl m Z m Z ddl mZddlmZmZmZdd lmZdd lmZdd lmZd d dgZejeƒZd&Zejdd'ƒZejdej d(ƒZ!ejde!j eƒZ"d „Z#iej$e#e!ƒd!6ej$e#e"ƒd"6Z%ie d!6e d"6Z&d efd#„ƒYZ'd e'fd$„ƒYZ(d%„Z)dS()i(tabsolute_importN(turljoini(tRecentlyUsedContainer(tHTTPConnectionPooltHTTPSConnectionPool(tport_by_scheme(tLocationValueErrort MaxRetryErrortProxySchemeUnknown(tRequestMethods(t parse_url(tRetryt PoolManagert ProxyManagertproxy_from_urltkey_filet cert_filet cert_reqstca_certst ssl_versiont ca_cert_dirt BasePoolKeytschemethosttportt HTTPPoolKeyttimeouttretrieststricttblocktsource_addresst HTTPSPoolKeycC@s_i}x$|jD]}|j|ƒ||>> 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 i cK@sMtj||ƒ||_t|dd„ƒ|_t|_tjƒ|_dS(Nt dispose_funccS@s |jƒS(N(tclose(tp((sN/tmp/pip-build-0nEYGB/pip/pip/_vendor/requests/packages/urllib3/poolmanager.pytys(R t__init__tconnection_pool_kwRtpoolstpool_classes_by_schemetkey_fn_by_schemetcopy(tselft num_poolstheadersR/((sN/tmp/pip-build-0nEYGB/pip/pip/_vendor/requests/packages/urllib3/poolmanager.pyR.us    cC@s|S(N((R4((sN/tmp/pip-build-0nEYGB/pip/pip/_vendor/requests/packages/urllib3/poolmanager.pyt __enter__€scC@s|jƒtS(N(tcleartFalse(R4texc_typetexc_valtexc_tb((sN/tmp/pip-build-0nEYGB/pip/pip/_vendor/requests/packages/urllib3/poolmanager.pyt__exit__ƒs cC@se|j|}|j}|dkrU|jjƒ}x!tD]}|j|dƒq8Wn||||S(s 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(R1R/R3t SSL_KEYWORDStpoptNone(R4RRRtpool_clstkwargstkw((sN/tmp/pip-build-0nEYGB/pip/pip/_vendor/requests/packages/urllib3/poolmanager.pyt _new_poolˆs    cC@s|jjƒdS(s΄ 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(R0R8(R4((sN/tmp/pip-build-0nEYGB/pip/pip/_vendor/requests/packages/urllib3/poolmanager.pyR8™sR(cC@sz|stdƒ‚n|jjƒ}|p-d|d<|sYtj|djƒdƒ}n||d<||d<|j|ƒS(sΦ Get a :class:`ConnectionPool` based on the host, port, and scheme. If ``port`` isn't given, it will be derived from the ``scheme`` using ``urllib3.connectionpool.port_by_scheme``. sNo host specified.R(RiPRR(RR/R3RR!R"tconnection_from_context(R4RRRR$((sN/tmp/pip-build-0nEYGB/pip/pip/_vendor/requests/packages/urllib3/poolmanager.pytconnection_from_host’s  cC@s6|djƒ}|j|}||ƒ}|j|ƒS(sβ Get a :class:`ConnectionPool` based on the request context. ``request_context`` must at least contain the ``scheme`` key and its value must be a key in ``key_fn_by_scheme`` instance variable. R(R"R2tconnection_from_pool_key(R4R$Rtpool_key_constructortpool_key((sN/tmp/pip-build-0nEYGB/pip/pip/_vendor/requests/packages/urllib3/poolmanager.pyREΆs  cC@s^|jjL|jj|ƒ}|r)|S|j|j|j|jƒ}||j| %sN(R RFRRRR9R6tproxyR@turlopent request_uritget_redirect_locationRtstatusR!t isinstanceR tfrom_intt incrementRtraise_on_redirecttlogtinfo( R4tmethodRLRPRCRMtconnRRtredirect_locationR((sN/tmp/pip-build-0nEYGB/pip/pip/_vendor/requests/packages/urllib3/poolmanager.pyRUδs8 $    "    N(t__name__t __module__t__doc__R@RTR.R7R=RDR8RFRERGRNtTrueRU(((sN/tmp/pip-build-0nEYGB/pip/pip/_vendor/requests/packages/urllib3/poolmanager.pyR Ws      cB@sGeZdZdddd„Zddd„Zdd„Zed„ZRS(sw 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 i cK@sΰt|tƒr.d|j|j|jf}nt|ƒ}|jsmtj|jdƒ}|jd|ƒ}n|jdkrŽt |jƒ‚n||_ |p i|_ |j |d<|j |dt namedtupleRR RRR'tpartialR2R1R R R(((sN/tmp/pip-build-0nEYGB/pip/pip/_vendor/requests/packages/urllib3/poolmanager.pytsD        ΐW