Edit File: poolmanager.pyc
� ��abc�����������@@��s���d��d�l��m�Z�d��d�l�Z�d��d�l�Z�d��d�l�Z�d�d�l�m�Z�d�d�l�m�Z�m �Z �d�d�l�m �Z �d�d�l�m�Z�m �Z �m�Z�d�d�l�m�Z�d�d �l�m�Z�d�d �l�m�Z�d�d�l�m�Z�d�d �d�g�Z�e�j�e���Z�d4�Z�d5�Z�e�j�d-�e���Z�d.����Z�i�e�j �e�e���d/�6e�j �e�e���d0�6Z!�i�e�d/�6e �d0�6Z"�d�e�f�d1�������YZ#�d �e#�f�d2�������YZ$�d3����Z%�d�S(6���i����(���t���absolute_importNi���(���t���RecentlyUsedContainer(���t���HTTPConnectionPoolt���HTTPSConnectionPool(���t���port_by_scheme(���t���LocationValueErrort ���MaxRetryErrort���ProxySchemeUnknown(���t���urljoin(���t���RequestMethods(���t ���parse_url(���t���Retryt���PoolManagert���ProxyManagert���proxy_from_urlt���key_filet ���cert_filet ���cert_reqst���ca_certst���ssl_versiont���ca_cert_dirt���ssl_contextt ���key_schemet���key_hostt���key_portt���key_timeoutt���key_retriest ���key_strictt ���key_blockt���key_source_addresst���key_key_filet ���key_cert_filet ���key_cert_reqst���key_ca_certst���key_ssl_versiont���key_ca_cert_dirt���key_ssl_contextt���key_maxsizet���key_headerst ���key__proxyt���key__proxy_headerst���key_socket_optionst���key__socks_optionst���key_assert_hostnamet���key_assert_fingerprintt���PoolKeyc���������C@��s��|�j�����}�|�d�j����|�d�<|�d�j����|�d�<xG�d�D]?�}�|�|�k�r;�|�|�d �k �r;�t�|�|�j������|�|�<q;�q;�W|�j�d���}�|�d �k �r��t�|���|�d�<n��x1�t�|�j������D]�}�|�j �|���|�d�|�<q��Wx*�|��j �D]�}�|�|�k�r��d �|�|�<q��q��W|��|����S( ���s��� Create a pool key out of a request context dictionary. According to RFC 3986, both the scheme and host are case-insensitive. Therefore, this function normalizes both before constructing the pool key for an HTTPS request. If you wish to change this behaviour, provide alternate callables to ``key_fn_by_scheme``. :param key_class: The class to use when constructing the key. This should be a namedtuple with the ``scheme`` and ``host`` keys at a minimum. :type key_class: namedtuple :param request_context: A dictionary-like object that contain the context for a request. :type request_context: dict :return: A namedtuple that can be used as a connection pool key. :rtype: PoolKey t���schemet���hostt���headerst���_proxy_headerst���_socks_optionst���socket_optionst���key_(���R0���R1���R2���N(���t���copyt���lowert���Nonet ���frozensett���itemst���gett���tuplet���listt���keyst���popt���_fields(���t ���key_classt���request_contextt���contextt���keyt���socket_optst���field(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyt���_default_key_normalizer9���s���� !t���httpt���httpsc�����������B@��s����e��Z�d��Z�d�Z�d�d�d���Z�d����Z�d����Z�d�d���Z�d����Z �d�d�d�d���Z �d ����Z�d�d ���Z�d�d���Z �d����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 ���c���������K@��sM���t��j�|��|���|�|��_�t�|�d�d�����|��_�t�|��_�t�j����|��_�d��S(���Nt���dispose_funcc���������S@��s ���|��j�����S(���N(���t���close(���t���p(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyt���<lambda>����t����(���R ���t���__init__t���connection_pool_kwR���t���poolst���pool_classes_by_schemet���key_fn_by_schemeR5���(���t���selft ���num_poolsR0���RO���(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRN�������s���� c���������C@��s���|��S(���N(����(���RS���(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyt ���__enter__����s����c���������C@��s���|��j�����t�S(���N(���t���cleart���False(���RS���t���exc_typet���exc_valt���exc_tb(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyt���__exit__����s���� c���������C@��s����|��j��|�}�|�d�k�r+�|��j�j����}�n��x�d�D]�}�|�j�|�d���q2�W|�d�k�r|�x!�t�D]�}�|�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/���t���portRG���N(���R.���R/���R\���(���RQ���R7���RO���R5���R>���t���SSL_KEYWORDS(���RS���R.���R/���R\���RA���t���pool_clsRC���t���kw(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyt ���_new_pool����s���� c���������C@��s���|��j��j����d�S(���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(���RP���RV���(���RS���(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRV�������s����RG���c���������C@��sz���|�s�t��d�����n��|��j�|���}�|�p-�d�|�d�<|�sY�t�j�|�d�j����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. s���No host specified.RG���R.���iP���R\���R/���(���R���t���_merge_pool_kwargsR���R:���R6���t���connection_from_context(���RS���R/���R\���R.���t���pool_kwargsRA���(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyt���connection_from_host����s���� c���������C@��s<���|�d�j�����}�|��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���(���R6���RR���t���connection_from_pool_key(���RS���RA���R.���t���pool_key_constructort���pool_key(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRb�������s���� c������ ���C@��sy���|��j��j��g�|��j��j�|���}�|�r)�|�S|�d�}�|�d�}�|�d�}�|��j�|�|�|�d�|��}�|�|��j��|�<Wd�QX|�S(���s���� Get a :class:`ConnectionPool` based on the provided pool key. ``pool_key`` should be a namedtuple that only contains immutable objects. At a minimum it must have the ``scheme``, ``host``, and ``port`` fields. R.���R/���R\���RA���N(���RP���t���lockR:���R`���(���RS���Rg���RA���t���poolR.���R/���R\���(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRe�������s���� c���������C@��s4���t��|���}�|��j�|�j�d�|�j�d�|�j�d�|��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.���Rc���(���R ���Rd���R/���R\���R.���(���RS���t���urlRc���t���u(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyt���connection_from_url ��s����!c���������C@��sq���|��j��j����}�|�rm�xU�|�j����D]D�\�}�}�|�d�k�r\�y�|�|�=Wqf�t�k �rX�qf�Xq"�|�|�|�<q"�Wn��|�S(���s�� Merge a dictionary of override values for self.connection_pool_kw. This does not modify self.connection_pool_kw and returns a new dict. Any keys in the override dictionary with a value of ``None`` are removed from the merged dictionary. N(���RO���R5���R9���R7���t���KeyError(���RS���t���overridet���base_pool_kwargsRC���t���value(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRa�����s���� c���������K@��s���t��|���}�|��j�|�j�d�|�j�d�|�j��}�t�|�d�<t�|�d�<d�|�k�rf�|��j�j����|�d�<n��|��j�d �k �r��|�j�d�k�r��|�j �|�|�|���}�n�|�j �|�|�j�|���}�|�o��|�j����}�|�s��|�St �|�|���}�|�j�d�k�r��d�}�n��|�j�d ���} �t�| �t���s-t�j�| �d�|��} �n��| �j�rq|�j�|���rqx(�| �j�D]�} �|�d�j�| �d ���qPWn��y"�| �j�|�|�d �|�d�|��} �Wn!�t�k �r�| �j�r����n��|�SX| �|�d �<|�|�d�<t�j�d�|�|���|��j �|�|�|���S(���s]�� Same as :meth:`urllib3.connectionpool.HTTPConnectionPool.urlopen` with custom cross-host redirect logic and only sends the request-uri portion of the ``url``. The given ``url`` parameter must be absolute, such that an appropriate :class:`urllib3.connectionpool.ConnectionPool` can be chosen for it. R\���R.���t���assert_same_hostt���redirectR0���RG���i/��t���GETt���retriest���responset���_pools���Redirecting %s -> %sN(���R ���Rd���R/���R\���R.���RW���R0���R5���t���proxyR7���t���urlopent���request_urit���get_redirect_locationR���t���statusR:���t ���isinstanceR���t���from_intt���remove_headers_on_redirectt���is_same_hostR>���t ���incrementR���t���raise_on_redirectt���logt���info(���RS���t���methodRj���Rr���R_���Rk���t���connRu���t���redirect_locationRt���t���header(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRx���-��s@���� $ " N(���t���__name__t ���__module__t���__doc__R7���Rw���RN���RU���R[���R`���RV���Rd���Rb���Re���Rl���Ra���t���TrueRx���(����(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyR���y���s��� c�����������B@��sJ���e��Z�d��Z�d�d�d�d���Z�d�d�d�d���Z�d�d���Z�e�d���Z�RS(���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 ���c���������K@��s����t��|�t���r.�d�|�j�|�j�|�j�f�}�n��t�|���}�|�j�sm�t�j�|�j�d���}�|�j�d�|���}�n��|�j�d�k�r��t �|�j�����n��|�|��_ �|�p��i��|��_�|��j �|�d�<|��j�|�d�<t�t �|����j�|�|�|���d��S( ���Ns ���%s://%s:%iiP���R\���RG���RH���t���_proxyR1���(���RG���RH���(���R|���R���R.���R/���R\���R ���R���R:���t���_replaceR���Rw���t ���proxy_headerst���superR ���RN���(���RS���t ���proxy_urlRT���R0���R����RO���Rw���R\���(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRN������s���� RG���c���������C@��sb���|�d�k�r.�t��t�|����j�|�|�|�d�|��St��t�|����j�|��j�j�|��j�j�|��j�j�d�|��S(���NRH���Rc���(���R����R ���Rd���Rw���R/���R\���R.���(���RS���R/���R\���R.���Rc���(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRd������s ����c���������C@��sI���i�d�d�6}�t��|���j�}�|�r/�|�|�d�<n��|�rE�|�j�|���n��|�S(���s���� Sets headers needed by proxies: specifically, the Accept and Host headers. Only sets headers not provided by the user. s���*/*t���Acceptt���Host(���R ���t���netloct���update(���RS���Rj���R0���t���headers_R����(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyt���_set_proxy_headers���s���� c���������K@��sk���t��|���}�|�j�d�k�rI�|�j�d�|��j���}�|��j�|�|���|�d�<n��t�t�|����j�|�|�d�|�|��S(���s@���Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute.RG���R0���Rr���(���R ���R.���R:���R0���R����R����R ���Rx���(���RS���R����Rj���Rr���R_���Rk���R0���(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRx������s ����N( ���R����R����R����R7���RN���Rd���R����R����Rx���(����(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyR ���i��s���c���������K@��s���t��d�|��|���S(���NR����(���R ���(���Rj���R_���(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyR������s����(���R���R���R���R���R���R���R���(���R���R���R���R���R���R���R���R���R���R���R ���R!���R"���R#���R$���R%���R&���R'���R(���R)���R*���R+���R,���(&���t ���__future__R����t���collectionst ���functoolst���loggingt���_collectionsR���t���connectionpoolR���R���R���t ���exceptionsR���R���R���t���packages.six.moves.urllib.parseR���t���requestR ���t���util.urlR ���t ���util.retryR���t���__all__t ���getLoggerR����R����R]���t���_key_fieldst ���namedtupleR-���RF���t���partialRR���RQ���R���R ���R���(����(����(����sC���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyt���<module>���sb�������������������������� 5 �W