HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //snap/certbot/4965/lib/python3.12/site-packages/requests/__pycache__/utils.cpython-312.pyc
�

M�h����^�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZmZddlmZddlmZddlmZmZmZmZdd	lmZmZmZmZmZmZm Z dd
lm!Z"ddlm#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)ddl*m+Z+dd
l,m-Z-m.Z.m/Z/m0Z0ddl1m2Z2dZ3ejh�Z5ddd�Z6djoejpded��d��Z9ejtdk(rd�Z;d�Z#d�Z<d�Z=dHd�Z>d�Z?d�Z@ej�d ��ZBd!�ZCd"�ZDd#�ZEd$�ZFdHd%�ZGd&�ZHd'�ZId(�ZJd)�ZKd*�ZLd+�ZMd,�ZNd-�ZOePd.�ZQd/�ZRd0�ZSd1�ZTd2�ZUd3�ZVd4�ZWej�d5��ZXd6�ZYdId7�ZZd8�Z[dJd9�Z\dKd:�Z]d;�Z^d<�Z_d=j�d>�Zaead?zZbead@zZcdA�ZddB�ZedC�ZfdD�ZgdE�ZhdF�ZidG�Zjy)Lz�
requests.utils
~~~~~~~~~~~~~~

This module provides utility functions that are used within Requests
that are also useful for external consumption.
�N)�OrderedDict)�make_headers�	parse_url�)�certs��__version__)�_HEADER_VALIDATORS_BYTE�_HEADER_VALIDATORS_STR�HEADER_VALIDATORS�to_native_string)�Mapping�
basestring�bytes�
getproxies�getproxies_environment�
integer_types�is_urllib3_1)�parse_http_list)�proxy_bypass�proxy_bypass_environment�quote�str�unquote�urlparse�
urlunparse��cookiejar_from_dict)�FileModeWarning�
InvalidHeader�
InvalidURL�UnrewindableBodyError)�CaseInsensitiveDict)z.netrc�_netrc�Pi�)�http�httpsz, z,\s*T)�accept_encodingzaccept-encoding�win32c��	ddl}	|j|jd�}t	|j|d�d�}|j|d�d}|r|sy|jd�}td|�}|D]j}|dk(rd|vry	|jdd
�}|jdd�}|jd
d�}tj||tj�s�jy	y#t$rYywxYw#ttf$rYywxYw)NrFz;Software\Microsoft\Windows\CurrentVersion\Internet Settings�ProxyEnable�
ProxyOverride�;z<local>�.Tz\.�*z.*�?)�winreg�ImportError�OpenKey�HKEY_CURRENT_USER�int�QueryValueEx�OSError�
ValueError�split�filter�replace�re�match�I)�hostr1�internetSettings�proxyEnable�
proxyOverride�tests      �~/build/snapcraft-certbot-c9561b03ef7f16aa90eb6754ca5f17a1/parts/certbot/install/lib/python3.12/site-packages/requests/utils.py�proxy_bypass_registryrEMs%��	��
	�%�~�~��(�(�N� ��
�f�1�1�2B�M�R�ST�U�V�K�"�/�/�0@�/�R�ST�U�M��-��
&�+�+�C�0�
��t�]�3�
�!�	�D��y� ��d�?���<�<��U�+�D��<�<��U�+�D��<�<��T�*�D��x�x��d�B�D�D�)��	���C�	��	����$�	��	�s#�C(�AC7�(	C4�3C4�7D	�D	c�B�t�rt|�St|�S)z�Return True, if the host should be bypassed.

        Checks proxy settings gathered from the environment, if specified,
        or the registry.
        )rrrE)r?s rDrrss ��"�#�+�D�1�1�(��.�.�c�>�t|d�r|j�}|S)z/Returns an internal sequence dictionary update.�items)�hasattrrI)�ds rD�dict_to_sequencerLs���q�'��
�G�G�I���HrGc��d}d}ts!t|t�r|jd�}t	|d�rt|�}n~t	|d�r
|j
}net	|d�rY	|j
�}tj|�j}d|jvrtjdt�	t	|d�rW	|j#�}t	|d	�r:|�8	|j%dd
�|j#�}|j%|xsd�|�d}t)d||z
�S#tjt f$rY��wxYw#t&$rd}Y�?wxYw#t&$r|�|}Y�RwxYw)Nr�utf-8�__len__�len�fileno�ba%Requests has determined the content-length for this request using the binary size of the file: however, the file has been opened in text mode (i.e. without the 'b' flag in the mode). This may lead to an incorrect content-length. In Requests 3.0, support will be removed for files in text mode.�tell�seek�)r�
isinstancer�encoderJrPrQ�os�fstat�st_size�mode�warnings�warnr�io�UnsupportedOperation�AttributeErrorrSrTr7�max)�o�total_length�current_positionrQs    rD�	super_lenre�sy���L����J�q�#�.�
�H�H�W����q�)���1�v��	��E�	��u�u��	��H�	�	��X�X�Z�F��8�8�F�+�3�3�L��!�&�&� ��
�
�2�$�
��q�&��	%� �v�v�x���q�&�!�l�&:�	%��F�F�1�a�L�#$�6�6�8�L��F�F�+�0�q�1������q�,�!1�1�2�2��e�'�'��8�	�
�		��X�%�#$�L�%��%�	0�
�'�#/� ��
	0�s6�*D8�E(�.7E�8E�E�E%�$E%�(
E8�7E8c���tjjd�}|�|f}n
d�tD�}	ddlm}m}d}|D]D}tjj|�}tjj|�s�B|}n|�yt|�}	|	j}
	||�j|
�}|r|drdnd}|||dfSy#|tf$r|r�YywxYw#ttf$rYywxYw)z;Returns the Requests tuple auth for a given url from netrc.�NETRCNc3�&K�|]	}d|�����y�w)z~/N�)�.0�fs  rD�	<genexpr>z!get_netrc_auth.<locals>.<genexpr>�s����9��R��s�8�9�s�r)�NetrcParseError�netrcrrU)rX�environ�get�NETRC_FILESrnrm�path�
expanduser�existsr�hostname�authenticatorsr7r2r`)
�url�raise_errors�
netrc_file�netrc_locationsrmrn�
netrc_pathrk�loc�rir?r$�login_is
             rD�get_netrc_authr�s��������(�J���%�-��9�[�9�� 
�0��
� �	�A��'�'�$�$�Q�'�C��w�w�~�~�c�"� �
��		����
�c�]���{�{��
	��:�&�5�5�d�;�F��%�a�y�!�a���w�����3�3��� ��)�	����	��
��(�
��
�s<�A
C#�C#�
C#�"+C�C �C#�C � C#�#C5�4C5c��t|dd�}|rBt|t�r1|ddk7r(|ddk7rtjj|�Syyyy)z0Tries to guess the filename of the given object.�nameNr�<����>)�getattrrVrrXrr�basename)�objr�s  rD�guess_filenamer��sT���3���%�D��
�4��,��a��C��D��H�PS�O��w�w����%�%�ET��,�trGc�R�tjj|�r|Stjj|�\}}|rytjj|�sZtjj|�\}}|sn5dj	||g�}|r tjj|�s�Ztj|�s|Stj|�}||j�vr|Stj�}tjj	||jd�d�}tjj|�s6t|�5}|j|j|��ddd�|S|S#1swY|SxYw)z�Replace nonexistent paths that look like they refer to a member of a zip
    archive with the location of an extracted copy of the target, or else
    just return the provided path unchanged.
    �/r�N)rXrrrtr9�join�zipfile�
is_zipfile�ZipFile�namelist�tempfile�
gettempdir�atomic_open�write�read)rr�archive�member�prefix�zip_file�tmp�extracted_path�file_handlers        rD�extract_zipped_pathsr�sE��

�w�w�~�~�d�����g�g�m�m�D�)�O�G�V�
�"�'�'�.�.��1��'�'�-�-��0�����
����6�6�*�+��
�"�'�'�.�.��1����g�&������w�'�H�
�X�&�&�(�(����
�
�
�C��W�W�\�\�#�v�|�|�C�'8��'<�=�N�
�7�7�>�>�.�)�
��
(�	6�L����x�}�}�V�4�5�	6���>��	6���s�/!F�F&c#�JK�tjtjj	|���\}}	tj
|d�5}|��ddd�tj||�y#1swY� xYw#t$rtj|��wxYw�w)z-Write a file to the disk in an atomic fashion)�dir�wbN)	r��mkstemprXrr�dirname�fdopenr;�
BaseException�remove)�filename�tmp_descriptor�tmp_name�tmp_handlers    rDr�r�'s����� (�/�/�B�G�G�O�O�H�4M�N��N�H��
�Y�Y�~�t�
,�	����	�
�
�
�8�X�&�	�	����
�	�	�(��
��s4�7B#�B�A4�B�3B#�4A=�9B� B � B#c�t�|�yt|ttttf�rtd��t
|�S)aTake an object and test to see if it can be represented as a
    dictionary. Unless it can not be represented as such, return an
    OrderedDict, e.g.,

    ::

        >>> from_key_val_list([('key', 'val')])
        OrderedDict([('key', 'val')])
        >>> from_key_val_list('string')
        Traceback (most recent call last):
        ...
        ValueError: cannot encode objects that are not 2-tuples
        >>> from_key_val_list({'key': 'val'})
        OrderedDict([('key', 'val')])

    :rtype: OrderedDict
    N�+cannot encode objects that are not 2-tuples)rVrr�boolr5r8r��values rD�from_key_val_listr�4s6��$
�}���%�#�u�d�C�0�1��F�G�G��u��rGc��|�yt|ttttf�rtd��t|t�r|j�}t|�S)a�Take an object and test to see if it can be represented as a
    dictionary. If it can be, return a list of tuples, e.g.,

    ::

        >>> to_key_val_list([('key', 'val')])
        [('key', 'val')]
        >>> to_key_val_list({'key': 'val'})
        [('key', 'val')]
        >>> to_key_val_list('string')
        Traceback (most recent call last):
        ...
        ValueError: cannot encode objects that are not 2-tuples

    :rtype: list
    Nr�)	rVrrr�r5r8rrI�listr�s rD�to_key_val_listr�OsJ��"
�}���%�#�u�d�C�0�1��F�G�G��%��!����
����;�rGc��g}t|�D]5}|dd|ddcxk(rdk(rnnt|dd�}|j|��7|S)aParse lists as described by RFC 2068 Section 2.

    In particular, parse comma-separated lists where the elements of
    the list may include quoted-strings.  A quoted-string could
    contain a comma.  A non-quoted string could have quotes in the
    middle.  Quotes are removed automatically after parsing.

    It basically works like :func:`parse_set_header` just that items
    may appear multiple times and case sensitivity is preserved.

    The return value is a standard :class:`list`:

    >>> parse_list_header('token, "quoted value"')
    ['token', 'quoted value']

    To create a header from the :class:`list` again, use the
    :func:`dump_header` function.

    :param value: a string with a list header.
    :return: :class:`list`
    :rtype: list
    Nrr��")�_parse_list_header�unquote_header_value�append)r��result�items   rD�parse_list_headerr�msY��.�F�"�5�)������8�t�B�C�y�'�C�'�'��Q�r�
�3�D��
�
�d����MrGc��i}t|�D]H}d|vrd||<�
|jdd�\}}|dd|ddcxk(rdk(rnnt|dd�}|||<�J|S)a^Parse lists of key, value pairs as described by RFC 2068 Section 2 and
    convert them into a python dict:

    >>> d = parse_dict_header('foo="is a fish", bar="as well"')
    >>> type(d) is dict
    True
    >>> sorted(d.items())
    [('bar', 'as well'), ('foo', 'is a fish')]

    If there is no value for a key it will be `None`:

    >>> parse_dict_header('key_without_value')
    {'key_without_value': None}

    To create a header from the :class:`dict` again, use the
    :func:`dump_header` function.

    :param value: a string with a dict header.
    :return: :class:`dict`
    :rtype: dict
    �=Nrr�r�)r�r9r�)r�r�r�r�s    rD�parse_dict_headerr��s}��,�F�"�5�)����d�?��F�4�L���j�j��a�(���e���!�9��b�c�
�)�c�)�(��q���5�E���t����MrGc��|rF|d|dcxk(rdk(r5n|S|dd}|r|dddk7r"|jdd�jd	d�S|S)
z�Unquotes a header value.  (Reversal of :func:`quote_header_value`).
    This does not use the real unquoting but what browsers are actually
    using for quoting.

    :param value: the header value to unquote.
    :rtype: str
    rr�r�rNrUz\\�\z\")r;)r��is_filenames  rDr�r��sd��
��q��U�2�Y�-�#�-��L��a�����e�B�Q�i�6�1��=�=���.�6�6�u�c�B�B��LrGc�X�|D�cic]}|j|j��}}|Scc}w)z�Returns a key/value dictionary from a CookieJar.

    :param cj: CookieJar object to extract cookies from.
    :rtype: dict
    )r�r�)�cj�cookie�cookie_dicts   rD�dict_from_cookiejarr��s/��<>�>��6�;�;����,�>�K�>����?s�'c��t||�S)z�Returns a CookieJar from a key/value dictionary.

    :param cj: CookieJar to insert cookies into.
    :param cookie_dict: Dict of key/values to insert into CookieJar.
    :rtype: CookieJar
    r)r�r�s  rD�add_dict_to_cookiejarr��s���{�B�/�/rGc�^�tjdt�tjdtj
��}tjdtj
��}tjd�}|j
|�|j
|�z|j
|�zS)zlReturns encodings from given content string.

    :param content: bytestring to extract encodings from.
    z�In requests 3.0, get_encodings_from_content will be removed. For more information, please see the discussion on issue #2266. (This warning should only appear once.)z!<meta.*?charset=["\']*(.+?)["\'>])�flagsz+<meta.*?content=["\']*;?charset=(.+?)["\'>]z$^<\?xml.*?encoding=["\']*(.+?)["\'>])r\r]�DeprecationWarningr<�compiler>�findall)�content�
charset_re�	pragma_re�xml_res    rD�get_encodings_from_contentr��s���

�M�M�
1�	�
����@����M�J��
�
�I�QS�QU�QU�V�I�
�Z�Z�?�
@�F�	���7�#�
�
�
�G�
$�	%�
�.�.��
!�	"�rGc�H�|jd�}|dj�|dd}}i}d}|D]m}|j�}|s�|d}}|jd�}	|	dk7r+|d|	j|�}||	dzdj|�}|||j�<�o||fS)	z�Returns content type and parameters from given header

    :param header: string
    :return: tuple containing content type and dictionary of
         parameters
    r-rrNz"' Tr�r�)r9�strip�find�lower)
�header�tokens�content_type�params�params_dict�items_to_strip�param�keyr��index_of_equalss
          rD�_parse_content_type_headerr��s����\�\�#�
�F�!�!�9�?�?�,�f�Q�R�j�&�L��K��N��-�����
������C�#�j�j��o�O��"�$��,�_�-�3�3�N�C���o��1�3�4�:�:�>�J��',�K��	�	��$�-���$�$rGc��|jd�}|syt|�\}}d|vr|djd�Sd|vryd|vryy)	z}Returns encodings from given HTTP Header Dict.

    :param headers: dictionary to extract encoding from.
    :rtype: str
    zcontent-typeN�charsetz'"�textz
ISO-8859-1zapplication/jsonrN)rpr�r�)�headersr�r�s   rD�get_encoding_from_headersr�s`���;�;�~�.�L���5�l�C��L�&��F���i� �&�&�u�-�-�
�����\�)��*rGc#�K�|j�|Ed{���ytj|j�d��}|D]}|j|�}|s�|���|jdd��}|r|��yy7�e�w)zStream decodes an iterator.Nr;��errorsrGT)�final)�encoding�codecs�getincrementaldecoder�decode)�iterator�r�decoder�chunk�rvs     rD�stream_decode_response_unicoder�*s�����	�z�z������6�f�*�*�1�:�:�6�i�H�G����
�^�^�E�
"��
��H��
����4��	(�B�	���
�	�s�A<�A:�AA<�"A<c#�K�d}|�|dkrt|�}|t|�kr||||z��||z
}|t|�kr�yy�w)z Iterate over slices of a string.rN)rP)�string�slice_length�poss   rD�iter_slicesr�;sW����
�C���|�q�0��6�{��

��F��
��S�3��-�.�.��|�����F��
�s�AA�Ac�>�tjdt�g}t|j�}|r	t|j|�S	t|j|d��S#t$r|j|�Y�5wxYw#t$r|jcYSwxYw)z�Returns the requested content back in unicode.

    :param r: Response object to get unicode content from.

    Tried:

    1. charset from content-type
    2. fall back and replace all unicode characters

    :rtype: str
    z�In requests 3.0, get_unicode_from_response will be removed. For more information, please see the discussion on issue #2266. (This warning should only appear once.)r;r�)
r\r]r�r�r�rr��UnicodeErrorr��	TypeError)r��tried_encodingsr�s   rD�get_unicode_from_responser�Es���
�M�M�
1�	�
��O�)����3�H��	-��q�y�y�(�+�+�
��1�9�9�h�y�9�9���	-��"�"�8�,�	-�����y�y���s#�A$�B�$B�B�B�BzBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~c��|jd�}tdt|��D]l}||dd}t|�dk(rI|j�r9	t	t|d��}|tvr|||ddz||<�Vd||��||<�bd||��||<�nd	j|�S#t$rtd|�d���wxYw)
z�Un-escape any percent-escape sequences in a URI that are unreserved
    characters. This leaves all reserved, illegal and non-ASCII bytes encoded.

    :rtype: str
    �%rrrU�z"Invalid percent-escape sequence: '�'N�)
r9�rangerP�isalnum�chrr5r8r!�UNRESERVED_SETr�)�uri�parts�i�h�cs     rD�unquote_unreservedr
rs���
�I�I�c�N�E�
�1�c�%�j�
!�
&���!�H�Q�q�M���q�6�Q�;�1�9�9�;�
L���A�r�
�O���N�"��u�Q�x���|�+��a���u�Q�x�j�>��a���5��8�*�~�E�!�H�
&��7�7�5�>����
L� �#E�a�S��!J�K�K�
L�s�B'�'Cc�p�d}d}	tt|�|��S#t$rt||��cYSwxYw)z�Re-quote the given URI.

    This function passes the given URI through an unquote/quote cycle to
    ensure that it is fully and consistently quoted.

    :rtype: str
    z!#$%&'()*+,/:;=?@[]~z!#$&'()*+,/:;=?@[]~)�safe)rr
r!)r�safe_with_percent�safe_without_percents   rD�requote_urir�sJ��/��0��	5��'��,�3D�E�E���5��S�3�4�4�	5�s��5�5c
�r�tjdtj|��d}|j	d�\}}tjdtjtt
|����d}tjdtj|��d|z}||z||zk(S)z�This function allows you to check if an IP belongs to a network subnet

    Example: returns True if ip = 192.168.1.1 and net = 192.168.1.0/24
             returns False if ip = 192.168.1.1 and net = 192.168.100.0/24

    :rtype: bool
    z=Lrr�)�struct�unpack�socket�	inet_atonr9�dotted_netmaskr5)�ip�net�ipaddr�netaddr�bits�netmask�networks       rD�address_in_networkr�s����]�]�4��!1�!1�"�!5�
6�q�
9�F��I�I�c�N�M�G�T��m�m�D�&�"2�"2�>�#�d�)�3L�"M�N�q�Q�G��m�m�D�&�"2�"2�7�";�<�Q�?�'�I�G��W��'�G�"3�4�4rGc�p�ddd|z
zdz
z}tjtjd|��S)z�Converts mask from /xx format to xxx.xxx.xxx.xxx

    Example: if mask is 24 function returns 255.255.255.0

    :rtype: str
    l��r� z>I)r�	inet_ntoar�pack)�maskrs  rDrr�s7����b�4�i��1�,�,�D����F�K�K��d�3�4�4rGc�N�	tj|�y#t$rYywxYw)z
    :rtype: bool
    FT)rrr7)�	string_ips rD�is_ipv4_addressr%�s.�������#�������s��	$�$c��|jd�dk(rR	t|jd�d�}|dks|dkDry	t	j
|jd�d�yy#t$rYywxYw#t$rYywxYw)zV
    Very simple check of the cidr format in no_proxy variable.

    :rtype: bool
    r�rFrrT)�countr5r9r8rrr7)�string_networkr"s  rD�
is_valid_cidrr)�s������C� �A�%�	��~�+�+�C�0��3�4�D��!�8�t�b�y��	����^�1�1�#�6�q�9�:�
����	��	���	��	�s"�A(�'A7�(	A4�3A4�7	B�Bc#�8K�|du}|r2tjj|�}|tj|<	d��|r(�tj|=y|tj|<yy#|r(�tj|=w|tj|<wwxYw�w)z�Set the environment variable 'env_name' to 'value'

    Save previous value, yield, and then restore the previous value stored in
    the environment variable 'env_name'.

    If 'value' is None, do nothingN)rXrorp)�env_namer��
value_changed�	old_values    rD�set_environr.�s�������%�M���J�J�N�N�8�,�	�$��
�
�8��1�
��� ��J�J�x�(�'0��
�
�8�$�	��=�� ��J�J�x�(�'0��
�
�8�$�	�s�9B�A+�+B�+,B�Bc��d�}|}|�|d�}t|�}|j�y|r�d�|jdd�jd�D�}t	|j�r=|D]7}t|�rt
|j|�s�%y|j|k(s�7yn_|j}|jr|d	|j��z
}|D]0}|jj|�s|j|�s�0ytd|�5	t|j�}ddd�ryy
#ttjf$rd
}Y�)wxYw#1swY�.xYw)zL
    Returns whether we should bypass proxies or not.

    :rtype: bool
    c��tjj|�xs-tjj|j��S�N)rXrorp�upper)r�s rD�	get_proxyz(should_bypass_proxies.<locals>.get_proxy�s-���z�z�~�~�c�"�A�b�j�j�n�n�S�Y�Y�[�&A�ArGN�no_proxyTc3�&K�|]	}|s�|���y�wr1ri)rjr?s  rDrlz(should_bypass_proxies.<locals>.<genexpr>
s����R�T�T�D�R�s��� r�,�:F)rrur;r9r%r)r�port�endswithr.rr�r�gaierror)	rwr4r3�no_proxy_arg�parsed�proxy_ip�host_with_portr?�bypasss	         rD�should_bypass_proxiesrA�sZ��B�
�L����Z�(��
�c�]�F�
������S�X�%5�%5�c�2�%>�%D�%D�S�%I�R���6�?�?�+�$�
 �� ��*�)�&�/�/�8�D�#��_�_��0� �
 �$�_�_�N��{�{��A�f�k�k�]�"3�3�� �
 ���?�?�+�+�D�1�^�5L�5L�T�5R� �	
 �
�Z��	.��	�!�&�/�/�2�F������
�6�?�?�+�	��F�	��	��s*�E�D2�2E�
E�E�E�Ec�4�t||��riSt�S)zA
    Return a dict of environment proxies.

    :rtype: dict
    �r4)rAr)rwr4s  rD�get_environ_proxiesrD0s���S�8�4��	��|�rGc�.�|xsi}t|�}|j�+|j|j|jd��S|jdz|jz|jd|jzdg}d}|D]}||vs�||}|S|S)z�Select a proxy for the url, if applicable.

    :param url: The url being for the request
    :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs
    N�allz://zall://)rrurp�scheme)rw�proxies�urlparts�
proxy_keys�proxy�	proxy_keys      rD�select_proxyrM<s����m��G���}�H���� ��{�{�8�?�?�G�K�K��,>�?�?�	���%��(�"3�"3�3�����8�$�$�$�
�	�J�
�E���	�����I�&�E���L��
�LrGc�8�|�|ni}|j}t|�j}|jd�}|j	�}|rOt||��sBt
||��}|j||jd��}|r|j||�|S)a�This method takes proxy information from a request and configuration
    input to resolve a mapping of target proxies. This will consider settings
    such as NO_PROXY to strip proxy configurations.

    :param request: Request or PreparedRequest
    :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs
    :param trust_env: Boolean declaring whether to trust environment configs

    :rtype: dict
    r4rCrF)rwrrGrp�copyrArD�
setdefault)	�requestrH�	trust_envrwrGr4�new_proxies�environ_proxiesrKs	         rD�resolve_proxiesrUVs���!�,�g�"�G�
�+�+�C�
�c�]�
!�
!�F��{�{�:�&�H��,�,�.�K��.�s�X�F�-�c�H�E���#�#�F�O�,?�,?��,F�G����"�"�6�5�1��rGc��|�dt��S)zO
    Return a string representing the default user agent.

    :rtype: str
    r�r)r�s rD�default_user_agentrWqs���V�1�[�M�"�"rGc�:�tt�tddd��S)z9
    :rtype: requests.structures.CaseInsensitiveDict
    z*/*z
keep-alive)z
User-AgentzAccept-Encoding�Accept�
Connection)r#rW�DEFAULT_ACCEPT_ENCODINGrirGrD�default_headersr\zs%���,�.�6��&�		
��rGc���g}d}|j|�}|s|Stjd|�D]�}	|jdd�\}}d|jd�i}|jd�D]:}	|jd�\}}|j|�||j|�<�<|j	|���|S#t$r|d}}Y��wxYw#t$rY�4wxYw)	z�Return a list of parsed link headers proxies.

    i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg"

    :rtype: list
    z '"z, *<r-rrrwz<> '"r�)r�r<r9r8r�)	r��links�
replace_chars�valrwr��linkr�r�s	         rD�parse_header_linksrb�s���
�E��M��K�K�
�&�E�����x�x���&���	"��)�)�C��+�K�C���s�y�y��*�+���\�\�#�&�	H�E�
�"�[�[��-�
��U�.3�[�[��-G�D����=�)�*�
	H�	���T��!�$�L���	"��r��C�	"���
��
�s#�B?�1C�?
C�C�	C�C��asciirU�c��|dd}|tjtjfvry|ddtjk(ry|ddtjtj
fvry|j
t�}|dk(ry	|dk(r |ddd�tk(ry
|ddd�tk(ry|dk(r|ddtk(ry
|ddtk(ryy)z
    :rtype: str
    N�zutf-32rez	utf-8-sigrUzutf-16rrNz	utf-16-berz	utf-16-lez	utf-32-bez	utf-32-le)
r��BOM_UTF32_LE�BOM_UTF32_BE�BOM_UTF8�BOM_UTF16_LE�BOM_UTF16_BEr'�_null�_null2�_null3)�data�sample�	nullcounts   rD�guess_json_utfrs�s����"�1�X�F�
�&�%�%�v�':�':�;�;��
�b�q�z�V�_�_�$��
�b�q�z�f�)�)�6�+>�+>�?�?�����U�#�I��A�~���A�~��#�A�#�;�&� ���!�$�Q�$�<�6�!���A�~��"�1�:�����!�"�:����rGc��t|�}|\}}}}}}}	|j}
|
s||
}}
|rdj||
g�}
|�|}|�d}t||
|d||	f�S)z�Given a URL that may or may not have a scheme, prepend the given scheme.
    Does not replace a present scheme with the one provided as an argument.

    :rtype: str
    �@r)r�netlocr�r)rw�
new_schemer=rG�authr?r9rr�query�fragmentrvs           rD�prepend_scheme_if_neededr{�s{���s�^�F�6<�3�F�D�$��d�E�8��]�]�F���V�������4��.�)��
�~����|����v�v�t�R���A�B�BrGc��t|�}	t|j�t|j�f}|S#tt
f$rd}Y|SwxYw)z{Given a url with authentication components, extract them into a tuple of
    username,password.

    :rtype: (str,str)
    )rr)rr�username�passwordr`r�)rwr=rxs   rD�get_auth_from_urlr�sU���c�]�F������(�'�&�/�/�*B�C���K��
�I�&�����K��s�*9�A�
Ac�B�|\}}t||d�t||d�y)z�Verifies that header parts don't contain leading whitespace
    reserved characters, or return characters.

    :param header: tuple, in the format (name, value).
    rrN)�_validate_header_part)r�r�r�s   rD�check_header_validityr�s%���K�D�%��&�$��*��&�%��+rGc
��t|t�r
t|}n7t|t�r
t|}ntd|�d|�dt
|�����|j|�s|dk(rdnd}td|�d|����y)	Nz
Header part (z) from z# must be of type str or bytes, not rr�r�zTInvalid leading whitespace, reserved character(s), or return character(s) in header z: )rVrrrr
r �typer=)r��header_part�header_validator_index�	validator�header_kinds     rDr�r�s����+�s�#�*�+A�B�	�	�K��	'�+�,B�C�	���K�?�'�&��:1�15�k�1B�0C�
E�
�	
�
�?�?�;�'� 6�!� ;�f����&�&1�]�"�[�O�
E�
�	
�(rGc�~�t|�\}}}}}}|s||}}|jdd�d}t|||||df�S)zW
    Given a url remove the fragment and the authentication part.

    :rtype: str
    rurr�r)r�rsplitr)rwrGrvrrr�ryrzs       rD�
urldefragauthr�sU��5=�S�M�1�F�F�D�&�%����V���
�]�]�3��
"�2�
&�F��v�v�t�V�U�B�?�@�@rGc���t|jdd�}|�.t|jt�r	||j�yt
d��#t
$rt
d��wxYw)zfMove file pointer back to its recorded starting position
    so it can be read again on redirect.
    rTNz;An error occurred when rewinding request body for redirect.z+Unable to rewind request body for redirect.)r��bodyrV�_body_positionrr7r")�prepared_request�	body_seeks  rD�rewind_bodyr�/st���(�-�-�v�t�<�I�����'�'��"�	��&�5�5�6�$�$Q�R�R���	�'�M��
�	�s�A�A()Fr1)T)zpython-requests)k�__doc__r��
contextlibr^rXr<rr�sysr�r\r��collectionsr�urllib3.utilrrrrr	�_internal_utilsr
rrr
�compatrrrrrrrrr�rrrrrrr�cookiesr�
exceptionsrr r!r"�
structuresr#rq�where�DEFAULT_CA_BUNDLE_PATH�
DEFAULT_PORTSr�r9r[�platformrErLrerr�r��contextmanagerr�r�r�r�r�r�r�r�r�r�r�r�r�r��	frozensetrr
rrrr%r)r.rArDrMrUrWr\rbrWrmrnrorsr{rr�r�r�r�rirGrD�<module>r�s�����	�	�	�
�
�
����#�0��$������:����)���,�"��$�������c�*�
��)�)��B�H�H�W�l�4�8�9J�K�L���
�<�<�7��$�L	/�
�D3�N)
�X&�"�J���	��	��6�<�@�F�2�0��2%�2�2�"�$�P�M���
�05�,5�5���0���1��1�*:�z	��4�6#��"�L	�
�
�g���	����	�����@C�:
� ,�
�&A�"SrG