σ β\e[c@@s„ddlmZddlZddlZddlZddlmZddlmZm Z ddlm Z ddl m Z m Z mZddlmZdd lmZdd lmZdd lmZd d dgZejeƒZd4Zd5Zejd-eƒZd.„Ziej eeƒd/6ej eeƒd06Z!ied/6e d06Z"d efd1„ƒYZ#d e#fd2„ƒYZ$d3„Z%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/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/poolmanager.pyt_default_key_normalizer9s  !  thttpthttpscB@s’eZdZdZddd„Zd„Zd„Zdd„Zd„Z dddd„Z d „Z dd „Z dd „Z d „Zed „ZRS(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 cK@sMtj||ƒ||_t|dd„ƒ|_t|_tjƒ|_dS(Nt dispose_funccS@s |jƒS(N(tclose(tp((s>/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/poolmanager.pyt›s(R t__init__tconnection_pool_kwRtpoolstpool_classes_by_schemetkey_fn_by_schemeR5(tselft num_poolsR0RN((s>/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/poolmanager.pyRM—s    cC@s|S(N((RR((s>/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/poolmanager.pyt __enter__’scC@s|jƒtS(N(tcleartFalse(RRtexc_typetexc_valtexc_tb((s>/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/poolmanager.pyt__exit__₯s cC@sŒ|j|}|dkr+|jjƒ}nxdD]}|j|dƒq2W|dkr|x!tD]}|j|dƒq_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(sschemeshostsport(RPR7RNR5R>t SSL_KEYWORDS(RRR.R/R[RAtpool_clsRCtkw((s>/tmp/pip-install-0xiv62/pip/pip/_vendor/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(RORU(RR((s>/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/poolmanager.pyRUΕsRGcC@sz|stdƒ‚n|j|ƒ}|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``. 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(RRR/R[R.t pool_kwargsRA((s>/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/poolmanager.pytconnection_from_hostΞs   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(R6RQtconnection_from_pool_key(RRRAR.tpool_key_constructortpool_key((s>/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/poolmanager.pyRaεs  c C@sy|jjg|jj|ƒ}|r)|S|d}|d}|d}|j|||d|ƒ}||j|/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/poolmanager.pyRdςs    cC@s4t|ƒ}|j|jd|jd|jd|ƒS(sΦ Similar to :func:`urllib3.connectionpool.connection_from_url`. If ``pool_kwargs`` is not provided and a new pool needs to be constructed, ``self.connection_pool_kw`` is used to initialize the :class:`urllib3.connectionpool.ConnectionPool`. If ``pool_kwargs`` is provided, it is used instead. Note that if a new pool does not need to be created for the request, the provided ``pool_kwargs`` are not used. R[R.Rb(R RcR/R[R.(RRturlRbtu((s>/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/poolmanager.pytconnection_from_url s !cC@sq|jjƒ}|rmxU|jƒD]D\}}|dkr\y ||=Wqftk rXqfXq"|||/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/poolmanager.pyR`s   c K@sρt|ƒ}|j|jd|jd|jƒ}t|d %sN(R RcR/R[R.RVR0R5tproxyR7turlopent request_uritget_redirect_locationRtstatusR:t isinstanceR tfrom_inttremove_headers_on_redirectt is_same_hostR>t incrementRtraise_on_redirecttlogtinfo( RRtmethodRiRqR^RjtconnRttredirect_locationRstheader((s>/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/poolmanager.pyRw-s@ $     "    N(t__name__t __module__t__doc__R7RvRMRTRZR_RURcRaRdRkR`tTrueRw(((s>/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/poolmanager.pyR ys       cB@sJeZdZdddd„Zdddd„Zdd„Zed„ZRS(sx 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 containing 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 |d/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/poolmanager.pyRM„s     RGcC@sb|dkr.tt|ƒj|||d|ƒStt|ƒj|jj|jj|jjd|ƒS(NRHRb(RŽR RcRvR/R[R.(RRR/R[R.Rb((s>/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/poolmanager.pyRc›s  cC@sIidd6}t|ƒj}|r/||d/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/poolmanager.pyt_set_proxy_headers£s  cK@skt|ƒ}|jdkrI|jd|jƒ}|j||ƒ|d/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/poolmanager.pyRw²s  N( R‡RˆR‰R7RMRcR•RŠRw(((s>/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/poolmanager.pyR is   cK@std||S(NR(R (RiR^((s>/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/poolmanager.pyRΐs(skey_files cert_files cert_reqssca_certss ssl_versions ca_cert_dirs ssl_context(s key_schemeskey_hostskey_ports key_timeouts key_retriess key_stricts key_blockskey_source_addresss key_key_files key_cert_files key_cert_reqss key_ca_certsskey_ssl_versionskey_ca_cert_dirskey_ssl_contexts key_maxsizes key_headerss key__proxyskey__proxy_headersskey_socket_optionsskey__socks_optionsskey_assert_hostnameskey_assert_fingerprint(&t __future__Rt collectionst functoolstloggingt _collectionsRtconnectionpoolRRRt exceptionsRRRtpackages.six.moves.urllib.parseRtrequestR tutil.urlR t util.retryR t__all__t getLoggerR‡RR\t _key_fieldst namedtupleR-RFtpartialRQRPR R R(((s>/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/poolmanager.pytsb    5 πW