usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyc000064400000035315147205651640021255 0ustar00 abc@@sddlmZddlZddlZddlZddlmZddlmZm Z ddlm Z ddl m Z m Z mZddlmZdd lmZdd lmZdd lmZd d dgZejeZd4Zd5Zejd-eZd.Ziej eed/6ej eed06Z!ied/6e d06Z"d efd1YZ#d e#fd2YZ$d3Z%dS(6i(tabsolute_importNi(tRecentlyUsedContainer(tHTTPConnectionPooltHTTPSConnectionPool(tport_by_scheme(tLocationValueErrort MaxRetryErrortProxySchemeUnknown(turljoin(tRequestMethods(t parse_url(tRetryt PoolManagert ProxyManagertproxy_from_urltkey_filet cert_filet cert_reqstca_certst ssl_versiont ca_cert_dirt ssl_contextt key_schemetkey_hosttkey_portt key_timeoutt key_retriest key_strictt key_blocktkey_source_addresst key_key_filet key_cert_filet key_cert_reqst key_ca_certstkey_ssl_versiontkey_ca_cert_dirtkey_ssl_contextt key_maxsizet key_headerst key__proxytkey__proxy_headerstkey_socket_optionstkey__socks_optionstkey_assert_hostnametkey_assert_fingerprinttPoolKeycC@s|j}|dj|d<|dj|d>> 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 |jS(N(tclose(tp((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pytt(R t__init__tconnection_pool_kwRtpoolstpool_classes_by_schemetkey_fn_by_schemeR5(tselft num_poolsR0RO((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRNs    cC@s|S(N((RS((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyt __enter__scC@s|jtS(N(tcleartFalse(RStexc_typetexc_valtexc_tb((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyt__exit__s cC@s|j|}|dkr+|jj}nxdD]}|j|dq2W|dkr|x!tD]}|j|dq_Wn||||S(s Create a new :class:`ConnectionPool` based on host, port, scheme, and any additional pool keyword arguments. If ``request_context`` is provided, it is provided as keyword arguments to the pool class used. 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.R/tportRGN(R.R/R\(RQR7ROR5R>t SSL_KEYWORDS(RSR.R/R\RAtpool_clsRCtkw((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyt _new_pools     cC@s|jjdS(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(RPRV(RS((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRVsRGcC@sz|stdn|j|}|p-d|d<|sYtj|djd}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``. If ``pool_kwargs`` is provided, it is merged with the instance's ``connection_pool_kw`` variable and used to create the new connection pool, if one is needed. sNo host specified.RGR.iPR\R/(Rt_merge_pool_kwargsRR:R6tconnection_from_context(RSR/R\R.t pool_kwargsRA((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pytconnection_from_hosts   cC@s<|dj}|j|}||}|j|d|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.RA(R6RRtconnection_from_pool_key(RSRAR.tpool_key_constructortpool_key((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRbs  c C@sy|jjg|jj|}|r)|S|d}|d}|d}|j|||d|}||j| %sN(R RdR/R\R.RWR0R5tproxyR7turlopent request_uritget_redirect_locationRtstatusR:t isinstanceR tfrom_inttremove_headers_on_redirectt is_same_hostR>t incrementRtraise_on_redirecttlogtinfo( RStmethodRjRrR_RktconnRutredirect_locationRttheader((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRx-s@ $     "    N(t__name__t __module__t__doc__R7RwRNRUR[R`RVRdRbReRlRatTrueRx(((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyR ys       cB@sJeZdZddddZddddZddZedZRS(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@st|tr.d|j|j|jf}nt|}|jsmtj|jd}|jd|}n|jdkrt |jn||_ |pi|_ |j |d<|j |dsb    5 W