ó b@RTc@s+ddlZyddlmZWn!ek rCddlmZnXddlmZddlmZm Z ddlm Z ddl m Z ddl mZdd lmZdd lmZd d d gZied6e d6ZejeƒZdZd efd„ƒYZd efd„ƒYZd„ZdS(iÿÿÿÿN(turljoini(tRecentlyUsedContainer(tHTTPConnectionPooltHTTPSConnectionPool(tport_by_scheme(tLocationValueError(tRequestMethods(t parse_url(tRetryt PoolManagert ProxyManagertproxy_from_urlthttpthttpstkey_filet cert_filet cert_reqstca_certst ssl_versioncBsYeZdZd Zdd d„Zd„Zd„Zd dd„Zd„Z e d„Z RS( s$ 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 i cKs5tj||ƒ||_t|dd„ƒ|_dS(Nt dispose_funccSs |jƒS(N(tclose(tp((sR/opt/freeware/lib/python2.7/site-packages/requests/packages/urllib3/poolmanager.pytAs(Rt__init__tconnection_pool_kwRtpools(tselft num_poolstheadersR((sR/opt/freeware/lib/python2.7/site-packages/requests/packages/urllib3/poolmanager.pyR=s  cCsbt|}|j}|dkrR|jjƒ}x!tD]}|j|dƒq5Wn||||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(tpool_classes_by_schemeRtcopyt SSL_KEYWORDStpoptNone(Rtschemethosttporttpool_clstkwargstkw((sR/opt/freeware/lib/python2.7/site-packages/requests/packages/urllib3/poolmanager.pyt _new_poolCs    cCs|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(Rtclear(R((sR/opt/freeware/lib/python2.7/site-packages/requests/packages/urllib3/poolmanager.pyR)TsR c Cs|stdƒ‚n|pd}|p6tj|dƒ}|||f}|jjC|jj|ƒ}|rq|S|j|||ƒ}||j| %sN(RR.R#R$R"tFalseRtproxyR!turlopent request_uritget_redirect_locationRtstatusR*t isinstanceRtfrom_intt incrementtlogtinfo( RtmethodR/R3R'R0tconntresponsetredirect_locationR5((sR/opt/freeware/lib/python2.7/site-packages/requests/packages/urllib3/poolmanager.pyR8…s, $     N( t__name__t __module__t__doc__R!R7RR(R)R.R1tTrueR8(((sR/opt/freeware/lib/python2.7/site-packages/requests/packages/urllib3/poolmanager.pyR s   cBsGeZdZdddd„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 cKsát|tƒr.d|j|j|jf}nt|ƒ}|jsmtj|jdƒ}|jd|ƒ}n|jd kst d|jƒ‚||_ |p¡i|_ |j |d<|j |ds*   ’W