� ��^i�u����dZddlZddlZddlZddlmZddlmZddlm Z ddl m Z m Z m Z mZmZddlmZmZmZmZdd lmZmZmZdd lmZmZdd lmZdd lmZm Z m!Z!dd l"m#Z#m$Z$m%Z%m&Z&ddl'm(Z(ddl)m*Z*ddlm+Z+m,Z,m-Z-m.Z.m/Z/m0Z0ddl1m2Z2ddlm3Z3ej4dkr ej5Z6n#e7$r ej8Z6Yn wxYwejZ6efd�Z9efd�Z:Gd�de;��Z<Gd�de<��Z=d�Z>dS)z� requests.sessions ~~~~~~~~~~~~~~~~~ This module provides a Session object to manage and persist settings across requests (cookies, auth, proxies). �N)� timedelta)� OrderedDict�)�_basic_auth_str)� cookielib�is_py3�urljoin�urlparse�Mapping)�cookiejar_from_dict�extract_cookies_to_jar�RequestsCookieJar� merge_cookies)�Request�PreparedRequest�DEFAULT_REDIRECT_LIMIT)� default_hooks� dispatch_hook)�to_native_string)�to_key_val_list�default_headers� DEFAULT_PORTS)�TooManyRedirects� InvalidSchema�ChunkedEncodingError�ContentDecodingError)�CaseInsensitiveDict)� HTTPAdapter)� requote_uri�get_environ_proxies�get_netrc_auth�should_bypass_proxies�get_auth_from_url� rewind_body)�codes)�REDIRECT_STATI�win32c�.�|�|S|�|St|t��rt|t��s|S|t|����}|�t|����d�|���D��}|D]}||=�|S)z�Determines appropriate setting for a given request, taking into account the explicit setting on that request, and the setting in the session. If a setting is a dictionary, they will be merged together using `dict_class` Nc��g|] \}}|�|�� S�N�)�.0�k�vs ��/builddir/build/BUILDROOT/alt-python311-pip-21.3.1-4.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_vendor/requests/sessions.py� z!merge_setting..Js��E�E�E�v��1�1�9��9�9�9�)� isinstancer r�update�items)�request_setting�session_setting� dict_class�merged_setting� none_keys�keys r/� merge_settingr;2s��� �������� ��� 0� 0�� ��� 0� 0�����Z��� @� @�A�A�N����/�/�:�:�;�;�;�F�E��!5�!5�!7�!7�E�E�E�I�� � �� �3� � � �r1c��|�|�d��gkr|S|�|�d��gkr|St|||��S)z�Properly merges both requests and session hooks. This is necessary because when request_hooks == {'response': []}, the merge breaks Session hooks entirely. N�response)�getr;)� request_hooks� session_hooksr7s r/� merge_hooksrAQs^�� �� � 1� 1�*� =� =�� C� C����� � 1� 1�*� =� =�� C� C��� �� �z� B� B�Br1c�8�eZdZd�Zd�Z d d�Zd�Zd�Zd �ZdS) �SessionRedirectMixinc��|jr9|jd}tr|�d��}t |d��SdS)z7Receives a Response. Returns a redirect URI or ``None``�location�latin1�utf8N)� is_redirect�headersr�encoder)�self�resprEs r/�get_redirect_targetz(SessionRedirectMixin.get_redirect_targetbsK�� � � 6��|�J�/�H�� 5�#�?�?�8�4�4��#�H�f�5�5� 5��tr1c�b�t|��}t|��}|j|jkrdS|jdkr|jdvr|jdkr |jdvrdS|j|jk}|j|jk}t j|jd��df}|s|j|vr |j|vrdS|p|S)zFDecide whether Authorization header should be removed when redirectingT�http)�PN�https)i�NFN)r �hostname�scheme�portrr>)rK�old_url�new_url� old_parsed� new_parsed� changed_port�changed_scheme� default_ports r/�should_strip_authz&SessionRedirectMixin.should_strip_authws����g�&�&� ��g�&�&� � � �*�"5� 5� 5��4� � �� '� '�J�O�z�,I�,I��%��0�0�Z�_� �5S�5S��5�"��*�/�9� �#�*�j�.?�?��%�)�*�*;�T�B�B�D�I� �� �:�?�l�#B�#B��O�|�3�3��5��-�~�-r1FNTc +��K�g} |�|��} t|j��j} | �r6|���} | �|��| dd�|_ |jn8#tttf$r|j � d���YnwxYwt|j��|jkr)td�|j��|����|���| �d��r=t|j��}d�t)|j��| g��} t| ��}|jd kr| r|�| � ��}n|jr|j} |���} |js#t3|jt5| ����} nt5| ��} t)| ��| _|�| |��|jt:jt:jfvr)d }|D]}| j �!|d���d| _"| j }|�!d d��tG| j$||j ��tK| j$|j&��| �'| j$��|�(| |��}|�)| |��| j*duod |vpd|v}|rtW| ��| }|r|V�nI|j,|f|||||dd�| ��}tG|j&| |j ��|�|��} |V�| ��4dSdS)zBReceives a Response. Returns a generator of Responses or Requests.rNF)�decode_contentzExceeded {} redirects.)r=z//�:�)�fragment)�Content-Lengthz Content-Type�Transfer-Encoding�Cookierbrc)�stream�timeout�verify�cert�proxies�allow_redirects)-rMr �urlra�copy�append�history�contentrr� RuntimeError�raw�read�len� max_redirectsr�format�close� startswith�joinrrS�_replace�geturl�netlocr r�rebuild_method� status_coder%�temporary_redirect�permanent_redirectrI�pop�bodyr �_cookiesr�cookies�prepare_cookies�rebuild_proxies� rebuild_auth�_body_positionr$�send)rKrL�reqrerfrgrhri�yield_requests�adapter_kwargs�histrk�previous_fragment�prepared_request� parsed_rurl�parsed�purged_headers�headerrI� rewindables r/�resolve_redirectsz&SessionRedirectMixin.resolve_redirects�s��������&�&�t�,�,��$�S�W�-�-�6���d �"�x�x�z�z� � �K�K�� � � �����8�D�L� 4�� � � ��(�*>� �M� 4� 4� 4��� � �U� �3�3�3�3�3� 4�����4�<� � �D�$6�6�6�&�'?�'F�'F�t�GY�'Z�'Z�ei�j�j�j�j� �J�J�L�L�L��~�~�d�#�#� L�&�t�x�0�0� ��h�h� 0��1C� D� D�c�J�K�K���c�]�]�F���"�$�$�):�$����2C��D�D����� 4�$*�O�!��-�-�/�/�C� �=� '��d�h� �C�(8�(8�9�9���!�#�&�&��#3�C�#8�#8� � � � � � 0�$� 7� 7� 7����(@�%�BZ�'[�[�[�!X��,�?�?�F�$�,�0�0���>�>�>�>�(,� �%�&�.�G� �K�K��$� '� '� '� #�#3�#<�c�4�8� L� L� L� �*�3�T�\� B� B� B� � ,� ,�-=�-F� G� G� G��*�*�+;�W�E�E�G� � � �.�� 5� 5� 5� !�/�t�;�P�!�W�,�N�0C�w�0N� � � .��,�-�-�-�#�C�� �� � � � �!�t�y�� �!�#�!��#�$)� � �%� � ��'�t�|�5E�t�x�P�P�P��.�.�t�4�4��� � � �I�d �d �d �d �d s�/A7�72B,�+B,c���|j}|j}d|vr#|�|jj|��r|d=|jrt |��nd}|�|�|��dSdS)z�When being redirected we may want to strip authentication from the request to avoid leaking credentials. This method intelligently removes and reapplies authentication where possible to avoid credential loss. � AuthorizationN)rIrkr\�request� trust_envr!� prepare_auth)rKr�r=rIrk�new_auths r/r�z!SessionRedirectMixin.rebuild_auth�s��� #�*���"�� �g� %� %�$�*@�*@��AQ�AU�WZ�*[�*[� %���(�+/�.�B�>�#�&�&�&�d�� � � � )� )�(� 3� 3� 3� 3� 3� � r1c��|�|ni}|j}|j}t|��j}|���}|�d��}t ||���}|jrT|sRt||���} | �|| �d����} | r|� || ��d|vr|d= t||��\} } n#t$rd\} } YnwxYw| r| rt| | ��|d<|S)a�This method re-evaluates the proxy configuration by considering the environment variables. If we are redirected to a URL covered by NO_PROXY, we strip the proxy configuration. Otherwise, we set missing proxy keys for this URL (in case they were stripped by a previous redirect). This method also replaces the Proxy-Authorization header where necessary. :rtype: dict N�no_proxy�r��allzProxy-Authorization�NN) rIrkr rSrlr>r"r�r � setdefaultr#�KeyErrorr) rKr�rirIrkrS� new_proxiesr�� bypass_proxy�environ_proxies�proxy�username�passwords r/r�z$SessionRedirectMixin.rebuild_proxiessM��%�0�'�'�b��"�*���"���#���%���l�l�n�n� ��;�;�z�*�*��,�S�8�D�D�D� � �>� 6�,� 6�1�#��I�I�I�O�#�'�'���0C�0C�E�0J�0J�K�K�E�� 6��&�&�v�u�5�5�5� �G� +� +��-�.� ,�!2�;�v�3F�!G�!G� �H�h�h��� ,� ,� ,�!+� �H�h�h�h� ,���� � Q�� Q�-<�X�x�-P�-P�G�)� *��s�C�C1�0C1c���|j}|jtjkr|dkrd}|jtjkr|dkrd}|jtjkr|dkrd}||_dS)z�When being redirected we may want to change the method of the request based on certain specs or browser behavior. �HEAD�GET�POSTN)�methodr}r%� see_other�found�moved)rKr�r=r�s r/r|z#SessionRedirectMixin.rebuild_method:s~��"�(�� � �5�?� 2� 2�v��7G�7G��F� � �5�;� .� .�6�V�3C�3C��F� � �5�;� .� .�6�V�3C�3C��F�"(����r1)FNTNNF) �__name__� __module__� __qualname__rMr\r�r�r�r|r+r1r/rCrC`s����������*.�.�.�2BF�OT�l�l�l�l�\4�4�4�&'�'�'�R)�)�)�)�)r1rCc��eZdZdZgd�Zd�Zd�Zd�Zd�Z dd �Z d �Z d �Z d �Z dd �Z dd�Zdd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS)�Sessiona�A Requests session. Provides cookie persistence, connection-pooling, and configuration. Basic Usage:: >>> import requests >>> s = requests.Session() >>> s.get('https://httpbin.org/get') Or as a context manager:: >>> with requests.Session() as s: ... s.get('https://httpbin.org/get') ) rIr��authri�hooks�paramsrgrh�adaptersrer�rtc��t��|_d|_i|_t ��|_i|_d|_d|_d|_ t|_ d|_ ti��|_t��|_|�dt%����|�dt%����dS)NFTzhttps://zhttp://)rrIr�rirr�r�rergrhrrtr�r r�rr��mountr�rKs r/�__init__zSession.__init__js��� '�(�(�� ��� � �� �#�_�_�� � �� ��� ��� ��� � 4������ +�2�.�.�� �$� � �� � � � �:�{�}�}�-�-�-� � � �9�k�m�m�,�,�,�,�,r1c��|Sr*r+r�s r/� __enter__zSession.__enter__�s��� r1c�.�|���dSr*)rv)rK�argss r/�__exit__zSession.__exit__�s�� � � � � � � � r1c��|jpi}t|tj��st |��}t t t ��|j��|��}|j}|jr|s|jst|j ��}t��}|� |j ���|j |j|j|jt%|j|jt(���t%|j|j��t%||j��|t-|j|j���� � |S)a�Constructs a :class:`PreparedRequest ` for transmission and returns it. The :class:`PreparedRequest` has settings merged from the :class:`Request ` instance and those of the :class:`Session`. :param request: :class:`Request` instance to prepare with this session's settings. :rtype: requests.PreparedRequest )r7) r�rk�files�data�jsonrIr�r�r�r�)r�r2r� CookieJarr rrr�r�r!rkr�preparer��upperr�r�r�r;rIrr�rAr�)rKr�r��merged_cookiesr��ps r/�prepare_requestzSession.prepare_request�s.���/�'�R���'�9�#6�7�7� 3�)�'�2�2�G�'� �+�-�-�t�|� <� <�g�G�G���|�� �>� /�$� /�t�y� /�!�'�+�.�.�D� � � �� � � ��>�'�'�)�)�� ��-�����!�'�/�4�<�L_�`�`�`� �����=�=��t�T�Y�/�/�"��g�m�T�Z�8�8� � � � ��r1NTc �"�t|���||||pi||pi||| �� � }|�|��}| pi} |�|j| | ||��}| | d�}|�|��|j|fi|��}|S)ax Constructs a :class:`Request `, prepares it and sends it. Returns :class:`Response ` object. :param method: method for the new :class:`Request` object. :param url: URL for the new :class:`Request` object. :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. :param json: (optional) json to send in the body of the :class:`Request`. :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`. :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`. :param files: (optional) Dictionary of ``'filename': file-like-objects`` for multipart encoding upload. :param auth: (optional) Auth tuple or callable to enable Basic/Digest/Custom HTTP Auth. :param timeout: (optional) How long to wait for the server to send data before giving up, as a float, or a :ref:`(connect timeout, read timeout) ` tuple. :type timeout: float or tuple :param allow_redirects: (optional) Set to True by default. :type allow_redirects: bool :param proxies: (optional) Dictionary mapping protocol or protocol and hostname to the URL of the proxy. :param stream: (optional) whether to immediately download the response content. Defaults to ``False``. :param verify: (optional) Either a boolean, in which case it controls whether we verify the server's TLS certificate, or a string, in which case it must be a path to a CA bundle to use. Defaults to ``True``. When set to ``False``, requests will accept any TLS certificate presented by the server, and will ignore hostname mismatches and/or expired certificates, which will make your application vulnerable to man-in-the-middle (MitM) attacks. Setting verify to ``False`` may be useful during local development or testing. :param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair. :rtype: requests.Response ) r�rkrIr�r�r�r�r�r�r�)rfrj)rr�r��merge_environment_settingsrkr3r�)rKr�rkr�r�rIr�r�r�rfrjrir�rergrhr�r��prep�settings� send_kwargsrLs r/r�zSession.request�s���\��<�<�>�>���������<�R����  �  �  ���#�#�C�(�(���-�R���2�2� �H�g�v�v�t� � �� �.� � � � ���8�$�$�$��t�y��-�-��-�-��� r1c �L�|�dd��|jd|fi|��S)z�Sends a GET request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response rjTr��r�r��rKrk�kwargss r/r>z Session.get"s7�� ���+�T�2�2�2��t�|�E�3�1�1�&�1�1�1r1c �L�|�dd��|jd|fi|��S)z�Sends a OPTIONS request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response rjT�OPTIONSr�r�s r/�optionszSession.options-s7�� ���+�T�2�2�2��t�|�I�s�5�5�f�5�5�5r1c �L�|�dd��|jd|fi|��S)z�Sends a HEAD request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response rjFr�r�r�s r/�headz Session.head8s7�� ���+�U�3�3�3��t�|�F�C�2�2�6�2�2�2r1c �&�|jd|f||d�|��S)a�Sends a POST request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. :param json: (optional) json to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response r�)r�r��r�)rKrkr�r�r�s r/�postz Session.postCs'���t�|�F�C�H�d��H�H��H�H�Hr1c �$�|jd|fd|i|��S)auSends a PUT request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response �PUTr�r��rKrkr�r�s r/�putz Session.putPs%���t�|�E�3�<�<�T�<�V�<�<��>�t�>�v�>�>�>r1c � �|jd|fi|��S)z�Sends a DELETE request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response �DELETEr�r�s r/�deletezSession.deletehs ���t�|�H�c�4�4�V�4�4�4r1c �H�|�d|j��|�d|j��|�d|j��|�d|�||j����t |t��rtd���|� dd��}|� d��}|j }|� |j ���}t��}|j|fi|��}t��|z } t!| � ��|_t%d ||fi|��}|jr*|jD]"} t)|j| j| j���#t)|j||j��|r|j||fi|��} d �| D��} ng} | r1| �d |��| � ��}| |_|s5 t5|j||fd di|����|_n#t8$rYnwxYw|s|j|S)zISend a given PreparedRequest. :rtype: requests.Response rergrhriz#You can only send PreparedRequests.rjT)rk)�secondsr=c��g|]}|��Sr+r+)r,rLs r/r0z Session.send..�s��,�,�,��t�,�,�,r1rr�)r�rergrhr�rir2r� ValueErrorr�r>r�� get_adapterrk�preferred_clockr�r�elapsedrrnr r�r�rqr��insert�next�_next� StopIterationro) rKr�r�rjrer��adapter�start�rr�rL�genrns r/r�z Session.sendrs��� ���(�D�K�0�0�0����(�D�K�0�0�0����&�$�)�,�,�,����)�T�%9�%9�'�4�<�%P�%P�Q�Q�Q� �g�w� '� '� D��B�C�C� C�!�*�*�%6��=�=�����H�%�%��� ���"�"�w�{�"�3�3�� �!�!�� �G�L�� +� +�F� +� +��"�#�#�e�+���g�.�.�.�� � �*�e�Q� 9� 9�&� 9� 9�� �9� M�� � M� M��&�t�|�T�\�4�8�L�L�L�L��t�|�W�a�e�<�<�<� � �(�$�(��G�>�>�v�>�>�C�,�,��,�,�,�G�G��G� � � �N�N�1�a� � � �� � � � �A��A�I�� � ��5�t�5�a��`�`�QU�`�Y_�`�`�a�a����� � � � ��� ����� � �I�I��s�%#H � H�Hc��|jr�|�|�d��nd}t||���}|���D]\}} |�|| ���|dus|�>t j�d��pt j�d��}t||j��}t||j ��}t||j ��}t||j ��}||||d�S)z^ Check the environment and merge it with some settings. :rtype: dict Nr�r�T�REQUESTS_CA_BUNDLE�CURL_CA_BUNDLE)rgrirerh) r�r>r r4r��os�environr;rirergrh) rKrkrirergrhr�� env_proxiesr-r.s r/r�z"Session.merge_environment_settings�s�� �>� <�29�2E�w�{�{�:�.�.�.�4�H�-�c�H�E�E�E�K�%�+�+�-�-� )� )���A��"�"�1�a�(�(�(�(���~�~����*�.�.�)=�>�>�;��*�.�.�)9�:�:�� ����6�6���v�t�{�3�3���v�t�{�3�3���T�4�9�-�-�� �W����� r1c���|j���D]B\}}|����|�����r|cS�Ct d�|�����)z~ Returns the appropriate connection adapter for the given URL. :rtype: requests.adapters.BaseAdapter z*No connection adapters were found for {!r})r�r4�lowerrwrru)rKrk�prefixr�s r/r�zSession.get_adapter�sz�� "&��!4�!4�!6�!6� � � �V�W��y�y�{�{�%�%�f�l�l�n�n�5�5� ����� ��H�O�O�PS�T�T�U�U�Ur1c�f�|j���D]}|����dS)z+Closes all adapters and as such the sessionN)r��valuesrv)rKr.s r/rvz Session.close�s8����%�%�'�'� � �A� �G�G�I�I�I�I� � r1c���||j�<�fd�|jD��}|D]$}|j�|��|j|<�%dS)zwRegisters a connection adapter to a prefix. Adapters are sorted in descending order by prefix length. c�T��g|]$}t|��t���k�"|��%Sr+)rs)r,r-r�s �r/r0z!Session.mount..�s/���I�I�I�a�C��F�F�S��[�[�4H�4H��4H�4H�4Hr1N)r�r�)rKr�r�� keys_to_mover:s ` r/r�z Session.mount�sd��� !(�� �f��I�I�I�I�4�=�I�I�I� �� 8� 8�C�!%��!2�!2�3�!7�!7�D�M�#� � � 8� 8r1c�.���fd��jD��}|S)Nc�4��i|]}|t�|d����Sr*)�getattr)r,�attrrKs �r/� z(Session.__getstate__..�s'���L�L�L�T��w�t�T�4�0�0�L�L�Lr1)� __attrs__)rK�states` r/� __getstate__zSession.__getstate__�s#���L�L�L�L�T�^�L�L�L��� r1c�\�|���D]\}}t|||���dSr*)r4�setattr)rKr r�values r/� __setstate__zSession.__setstate__�s<�� �;�;�=�=� '� '�K�D�%� �D�$�� &� &� &� &� '� 'r1)NNNNNNNTNNNNNNr�r*)r�r�r��__doc__r r�r�r�r�r�r>r�r�r�r�r�r�r�r�r�rvr�r rr+r1r/r�r�Qs��������$���I� <-�<-�<-�|������&�&�&�RGK�CG�BF�J�J�J�J�X 2� 2� 2� 6� 6� 6� 3� 3� 3� I� I� I� I� =� =� =� =� ?� ?� ?� ?�5�5�5�I�I�I�V���: V� V� V���� 8� 8� 8����'�'�'�'�'r1r�c��t��S)aZ Returns a :class:`Session` for context-management. .. deprecated:: 1.0.0 This method has been deprecated since version 1.0.0 and is only kept for backwards compatibility. New code should use :class:`~requests.sessions.Session` to create a session. This may be removed at a future date. :rtype: Session )r�r+r1r/�sessionrs�� �9�9�r1)?rr��sys�time�datetimer� collectionsrr�r�compatrrr r r r�r r rr�modelsrrrr�rr�_internal_utilsr�utilsrrr� exceptionsrrrr� structuresrr�rrr r!r"r#r$� status_codesr%r&�platform� perf_counterr��AttributeError�clockr;rA�objectrCr�rr+r1r/�r#s&���� � � � � � � � � � � � �������#�#�#�#�#�#�!�!�!�!�!�!�A�A�A�A�A�A�A�A�A�A�A�A�A�A�S�S�S�S�S�S�S�S�S�S�S�S�D�D�D�D�D�D�D�D�D�D�/�/�/�/�/�/�/�/�-�-�-�-�-�-�B�B�B�B�B�B�B�B�B�B�Q�Q�Q�Q�Q�Q�Q�Q�Q�Q�Q�Q�,�+�+�+�+�+�!�!�!�!�!�!�����������������  ������#�"�"�"�"�"��<�7���%��+���� �%�%�%��*����%�����i�O�@K�����>:E� C� C� C� C�n)�n)�n)�n)�n)�6�n)�n)�n)�bm'�m'�m'�m'�m'�"�m'�m'�m'�` � � � � s�B%�% B4�3B4