� ��^i3M���ddlmZddlZddlZddlZddlmZddlmZm Z m Z ddl m Z m Z mZmZmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZgd �Zeje��Z dZ!dZ"ej#de"��Z$dZ%ej#de%��Z&d�Z'ej(e'e$��ej(e'e$��d�Z)ee d�Z*Gd�de��Z+Gd�de+��Z,d�Z-dS)�)�absolute_importN�)�RecentlyUsedContainer)�HTTPConnectionPool�HTTPSConnectionPool�port_by_scheme)�LocationValueError� MaxRetryError�ProxySchemeUnknown�ProxySchemeUnsupported�URLSchemeUnknown)�six)�urljoin)�RequestMethods)�connection_requires_http_tunnel)�Retry)� parse_url)� PoolManager� ProxyManager�proxy_from_url)�key_file� cert_file� cert_reqs�ca_certs� ssl_version� ca_cert_dir� ssl_context� key_password)� key_scheme�key_host�key_port� key_timeout� key_retries� key_strict� key_block�key_source_address� key_key_file�key_key_password� key_cert_file� key_cert_reqs� key_ca_certs�key_ssl_version�key_ca_cert_dir�key_ssl_context� key_maxsize� key_headers� key__proxy�key__proxy_headers�key__proxy_config�key_socket_options�key__socks_options�key_assert_hostname�key_assert_fingerprint�key_server_hostname�PoolKey)r�use_forwarding_for_https� ProxyConfigc��|���}|d���|d<|d���|d<dD]8}||vr2||�*t||�����||<�9|�d��}|�t |��|d<t |�����D]}|�|��|d|z<�|j D] }||vrd||<� |di|��S)a� 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 �scheme�host)�headers�_proxy_headers�_socks_optionsN�socket_options�key_�) �copy�lower� frozenset�items�get�tuple�list�keys�pop�_fields)� key_class�request_context�context�key� socket_opts�fields ��/builddir/build/BUILDROOT/alt-python311-pip-21.3.1-4.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_vendor/urllib3/poolmanager.py�_default_key_normalizerrVNs8��*�"�"�$�$�G���)�/�/�1�1�G�H���f�o�+�+�-�-�G�F�O�?�;�;�� �'�>�>�g�c�l�6�$�W�S�\�%7�%7�%9�%9�:�:�G�C�L���+�+�.�/�/�K���$)�+�$6�$6�� �!��G�L�L�N�N�#�#�1�1�� '� � �C� 0� 0���� ����"�"�"�� �� � �!�G�E�N�� �9� � �w� � ����http�httpsc�t�eZdZdZdZdZdd�Zd�Zd�Zdd�Z d�Z dd �Z d �Z dd �Z dd �Zd�Zd�Zd�Zdd�ZdS)ra$ 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 N� c ���tj||��||_t|d����|_t |_t ���|_dS)Nc�*�|���S�N)�close)�ps rU�z&PoolManager.__init__..�s��Q�W�W�Y�Y�rW)� dispose_func)r�__init__�connection_pool_kwr�pools�pool_classes_by_scheme�key_fn_by_schemerE)�self� num_poolsr?res rUrdzPoolManager.__init__�sY�����g�.�.�.�"4���*�9�CV�CV�W�W�W�� �'=��#� 0� 5� 5� 7� 7����rWc��|Sr_rD�ris rU� __enter__zPoolManager.__enter__�s��� rWc�.�|���dS)NF)�clear)ri�exc_type�exc_val�exc_tbs rU�__exit__zPoolManager.__exit__�s�� � � � � � ��urWc���|j|}|�|j���}dD]}|�|d���|dkr tD]}|�|d���|||fi|��S)a� Create a new :class:`urllib3.connectionpool.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. N)r=r>�portrY)rgrerErM� SSL_KEYWORDS)rir=r>rurP�pool_clsrR�kws rU� _new_poolzPoolManager._new_pool�s����.�v�6�� � "�"�5�:�:�<�<�O� .� +� +�C� � � ��T� *� *� *� *� �V� � �"� .� .���#�#�B��-�-�-�-��x��d�6�6�o�6�6�6rWc�8�|j���dS)z� 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)rfrorls rUrozPoolManager.clear�s�� � �������rWrYc���|std���|�|��}|pd|d<|s-tj|d���d��}||d<||d<|�|��S)a� Get a :class:`urllib3.connectionpool.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. zNo host specified.rYr=�Prur>)r �_merge_pool_kwargsrrIrF�connection_from_context)rir>rur=� pool_kwargsrPs rU�connection_from_hostz PoolManager.connection_from_host�s���� ;�$�%9�:�:� :��1�1�+�>�>��$*�$4�f���!�� M�!�%�o�h�&?�&E�&E�&G�&G��L�L�D�"&����"&�����+�+�O�<�<�rur�)rf�lockrIry)rir�rP�poolr=r>rus rUr�z$PoolManager.connection_from_pool_keys����Z�_� (� (��:�>�>�(�+�+�D�� �� (� (� (� (� (� (� (� (�%�X�.�F�"�6�*�D�"�6�*�D��>�>�&�$��o�>�V�V�D�#'�D�J�x� � (� (� (� (� (� (� (� (� (� (� (���� (� (� (� (�� s�A?�;A?�?B�Bc�p�t|��}|�|j|j|j|���S)a� 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. )rur=r)rr�r>rur=)ri�urlr�us rU�connection_from_urlzPoolManager.connection_from_urls;�� �c�N�N���(�(� �F�����k�)� � � rWc��|j���}|r6|���D]!\}}|� ||=� #t$rY�wxYw|||<�"|S)a 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. )rerErH�KeyError)ri�override�base_pool_kwargsrR�values rUr}zPoolManager._merge_pool_kwargs.s��� �2�7�7�9�9�� � 2�&�n�n�.�.� 2� 2� ��U��=��,�S�1�1��#����������-2�$�S�)�)��s�<� A �A c�V�|j�dSt|j|j|j�� S)z� Indicates if the proxy requires the complete destination URL in the request. Normally this is only needed when not using an HTTP CONNECT tunnel. NF)�proxyr� proxy_configr=)ri� parsed_urls rU�!_proxy_requires_url_absolute_formz-PoolManager._proxy_requires_url_absolute_formBs7�� �:� ��5�2� �J��)�:�+<� � � � rWc��|j�|dkrdS|jjdkrdStjr|jjst d���dSdS)z� Validates that were not attempting to do TLS in TLS connections on Python2 or with unsupported SSL implementations. NrZzfContacting HTTPS destinations through HTTPS proxies 'via CONNECT tunnels' is not supported in Python 2)r�r=r�PY2r�r:r )ri� url_schemes rU�$_validate_proxy_scheme_url_selectionz0PoolManager._validate_proxy_scheme_url_selectionOss�� �:� ��w�!6�!6� �F� �:� �� '� '� �F� �7� �4�,�E� �(�E��� � � � � rWTc �x�t|��}|�|j��|�|j|j|j���}d|d<d|d<d|vr|j���|d<|�|��r|j ||fi|��}n|j ||j fi|��}|o|� ��}|s|St||��}|j dkrd}|�d��} t| t ��st!j| |� ��} | jrx|�|��sct)t+j|d����} | D]9} | ���| jvr|d�| d ���: | �||||� ��} n.#t4$r!| jr|����|cYSwxYw| |d<||d<t:�d ||��|���|j ||fi|��S) aN Same as :meth:`urllib3.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. )rur=F�assert_same_host�redirectr?i/�GET�retries)r�N)�response�_poolzRedirecting %s -> %s)rr�r=r�r>rur?rEr��urlopen� request_uri�get_redirect_locationr�statusrI� isinstancer�from_int�remove_headers_on_redirect� is_same_hostrKr�iterkeysrFrM� incrementr �raise_on_redirect� drain_conn�log�info) ri�methodr�r�rxr��connr��redirect_locationr�r?�headers rUr�zPoolManager.urlopen`s��� �c�N�N�� �1�1�!�(�;�;�;��(�(���a�f�Q�X�(�N�N��!&�� ����:�� �B� � � �L�-�-�/�/�B�y�M� � 1� 1�!� 4� 4� A�#�t�|�F�C�6�6�2�6�6�H�H�#�t�|�F�A�M�@�@�R�@�@�H�$�I��)G�)G�)I�)I�� � ��O�$�C�):�;�;�� �?�c� !� !��F��&�&��#�#���'�5�)�)� A��n�W�x�@�@�@�G� � -� 4�d�6G�6G� �7 �7 � 4��3�<��9� �6�6�7�7�G�!� 4� 4���<�<�>�>�W�%G�G�G��y�M�%�%�f�d�3�3�3�� ��'�'���h�d�'�S�S�G�G��� � � ��(� ��#�#�%�%�%���O�O�O�  ����  ��9� �!��:�� ���'��.?�@�@�@��������t�|�F�$5�<�<��<�<� 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. :param proxy_ssl_context: The proxy SSL context is used to establish the TLS connection to the proxy when using HTTPS proxies. :param use_forwarding_for_https: (Defaults to False) If set to True will forward requests to the HTTPS proxy to be made on behalf of the client instead of creating a TLS tunnel via the CONNECT method. **Enabling this flag means that request and response headers and content will be visible from the HTTPS proxy** whereas tunneling keeps request and response headers and content private. IP address, target hostname, SNI, and port are always visible to an HTTPS proxy even when this flag is disabled. 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 r\NFc ����t|t��rd|j|j|jfz}t |��}|jdvrt |j���|js0tj|jd��} |� | ���}||_ |pi|_ ||_ t||��|_|j |d<|j |d<|j|d<tt |��j||fi|��dS)Nz %s://%s:%irXr|)ru�_proxyr@� _proxy_config)r�rr=r>rurr rrI�_replacer�� proxy_headers�proxy_ssl_contextr;r��superrrd) ri� proxy_urlrjr?r�r�r:rer�ru� __class__s �rUrdzProxyManager.__init__�s��� �i�!3� 4� 4� �$�� �����(��I� �)�$�$�� �<�0� 0� 0�$�U�\�2�2� 2��z� .�!�%�e�l�B�7�7�D��N�N��N�-�-�E��� �*�0�b���!2���'�(9�;S�T�T���'+�z��8�$�/3�/A��+�,�.2�.?��?�+�*��l�D�!�!�*�9�g�T�T�AS�T�T�T�T�TrWrYc����|dkr,tt|���||||���Stt|���|jj|jj|jj|���S)NrZ)r)r�rr�r�r>rur=)rir>rur=rr�s �rUr�z!ProxyManager.connection_from_host�s~��� �W� � ���t�,�,�A�A��d�F� �B��� ��\�4�(�(�=�=� �J�O�T�Z�_�d�j�.?�[�>� � � rWc�r�ddi}t|��j}|r||d<|r|�|��|S)z� Sets headers needed by proxies: specifically, the Accept and Host headers. Only sets headers not provided by the user. �Acceptz*/*�Host)r�netloc�update)rir�r?�headers_r�s rU�_set_proxy_headerszProxyManager._set_proxy_headers�sM�� �e�$���3���&�� � &�%�H�V� � � %� �O�O�G� $� $� $��rWTc ���t|��}t|j|j|j��s4|�d|j��}|�||��|d<tt|��j ||fd|i|��S)z@Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute.r?r�) rrr�r�r=rIr?r�r�rr�)rir�r�r�rxr�r?r�s �rUr�zProxyManager.urlopen s���� �c�N�N��.�t�z�4�;L�a�h�W�W� B��f�f�Y�� �5�5�G� �3�3�C��A�A�B�y�M�0�u�\�4�(�(�0���V�V�x�V�SU�V�V�VrW)r\NNNFr�r_r�) r�r�r�r�rdr�r�r�� __classcell__)r�s@rUrr�s��������%�%�T����!&�#U�#U�#U�#U�#U�#U�J � � � � � � � � � � W� W� W� W� W� W� W� W� W� WrWrc ��tdd|i|��S)Nr�rD)r)r�rxs rUrrs�� � ,� ,�#� ,�� ,� ,�,rW).� __future__r� collections� functools�logging� _collectionsr�connectionpoolrrr� exceptionsr r r r r �packagesr�packages.six.moves.urllib.parser�requestr� util.proxyr� util.retryr�util.urlr�__all__� getLoggerr�r�rv� _key_fields� namedtupler9�_proxy_config_fieldsr;rV�partialrhrgrrrrDrWrU�r�sW��&�&�&�&�&�&�������������/�/�/�/�/�/�S�S�S�S�S�S�S�S�S�S���������������������4�4�4�4�4�4�#�#�#�#�#�#�7�7�7�7�7�7������������� ;� ;� ;���g���!�!�� � �� �> !�+� ��K� 8� 8��B��$�k�$�]�4H�I�I� �. �. �. �l �I� �5�w� ?� ?� �Y� �6�� @� @���� #5�?R�S�S��V=�V=�V=�V=�V=�.�V=�V=�V=�rpW�pW�pW�pW�pW�;�pW�pW�pW�f-�-�-�-�-rW