ó éù Rc@s ddlZyddlmZWn!ek rCddlmZnXddlmZddlmZm Z ddlm Z ddl m Z ddl mZd d d gZied 6e d 6ZejeƒZdZd e fd„ƒYZd efd„ƒYZd„ZdS(iÿÿÿÿN(turljoini(tRecentlyUsedContainer(tHTTPConnectionPooltHTTPSConnectionPool(tport_by_scheme(tRequestMethods(t parse_urlt 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((s7/usr/lib/python2.7/dist-packages/urllib3/poolmanager.pytEs(Rt__init__tconnection_pool_kwRtpools(tselft num_poolstheadersR((s7/usr/lib/python2.7/dist-packages/urllib3/poolmanager.pyRAs  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((s7/usr/lib/python2.7/dist-packages/urllib3/poolmanager.pyt _new_poolGs    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((s7/usr/lib/python2.7/dist-packages/urllib3/poolmanager.pyR'XsR c Csˆ|p d}|p!tj|dƒ}|||f}|jjC|jj|ƒ}|r\|S|j|||ƒ}||j| %stretriesiiN(RR,R!R"R tFalseRtproxyRturlopent request_uritget_redirect_locationRtstatustlogtinfoR(( RtmethodR-R1R%R.tconntresponsetredirect_location((s7/usr/lib/python2.7/dist-packages/urllib3/poolmanager.pyR6‡s& $     N( t__name__t __module__t__doc__RR5RR&R'R,R/tTrueR6(((s7/usr/lib/python2.7/dist-packages/urllib3/poolmanager.pyR#s   cBsGeZdZdddd„Zddd„Zdd„Zed„ZRS(sv Behaves just like :class:`PoolManager`, but sends all requests through the defined proxy, using the CONNECT method for HTTPS URLs. :param poxy_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||_ |pi|_ |j jd ks­t d|j jƒ‚|j |d<|j |ds&   ‹T