o
    Ø­jâ�  ã                   @  sB  U d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	Z	ddl
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mZmZmZmZmZ ddlmZmZ dd	lmZ dd
lmZ ddl m!Z!m"Z"m#Z#m$Z$ ddl%m&Z' ddl(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5 ddl(m6Z7 ddl8m9Z9 ddl:m;Z;m<Z<m=Z=m>Z> ddl?m@Z@ erÓddlAmBZB ddlmCZC ddlm%ZD ddlEmFZFmGZGmHZH dZIdeJd< e K¡ ZLdeJd< dddœZMdeJd< edƒZNed ƒZOd! Pe Qd"ed#d$�d% ¡¡ZRdeJd&< e
jSd'k�rdÕd+d,„ZTdÕd-d.„Z/dÖd2d3„ZUd×d7d8„ZV	9dØdÙd>d?„ZWdÚdBdC„ZXdÛdEdF„ZYejZdÜdIdJ„ƒZ[dÝdNdO„Z\edÞdQdR„ƒZ]edßdUdR„ƒZ]dàdXdR„Z]dádZd[„Z^dâd]d^„Z_dØdãd`da„Z`däddde„Zadådhdi„Zbdædkdl„Zcdçdodp„Zddèdsdt„Zedédzd{„Zfedêd�d‚„ƒZgedëd„d‚„ƒZgdìd‡d‚„Zgdíd‰dŠ„Zheid‹ƒZjdeJdŒ< dîdŽd�„Zkdîd�d‘„Zldïd”d•„Zmdðd—d˜„Zndñdšd›„Zodòd�dž„ZpejZdód¡d¢„ƒZqdôd¤d¥„Zrdõdöd¦d§„Zsd÷dªd«„Zt	#dødùd¯d°„Zudúdûd³d´„Zvdüdµd¶„Zwdýd¸d¹„Zxdº yd»¡Zzezd¼ Z{ezd½ Z|dþd¿dÀ„Z}dÿdÂdÃ„Z~�d dÅdÆ„Z�ddÈdÉ„Z€�ddÍdÎ„Z��ddÏdÐ„Z‚�ddÓdÔ„ZƒdS (  z”
requests.utils
~~~~~~~~~~~~~~

This module provides utility functions that are used within Requests
that are also useful for external consumption.
é    )ÚannotationsN)ÚOrderedDict)Ú	GeneratorÚIterable)ÚTYPE_CHECKINGÚAnyÚFinalÚTypeVarÚcastÚoverload)Úmake_headersÚ	parse_urlé   )Úcerts©Ú__version__)Ú_HEADER_VALIDATORS_BYTEÚ_HEADER_VALIDATORS_STRÚHEADER_VALIDATORSÚto_native_string)ÚSupportsItems)ÚMappingÚbytesÚ
getproxiesÚgetproxies_environmentÚinteger_typesÚis_urllib3_1Úproxy_bypassÚproxy_bypass_environmentÚquoteÚstrÚunquoteÚurlparseÚ
urlunparse)Úparse_http_list©Úcookiejar_from_dict)ÚFileModeWarningÚInvalidHeaderÚ
InvalidURLÚUnrewindableBodyError)ÚCaseInsensitiveDict)Ú	CookieJar)ÚBufferedWriter)Ú_types)ÚPreparedRequestÚRequestÚResponse)z.netrcÚ_netrcr   ÚNETRC_FILESr    ÚDEFAULT_CA_BUNDLE_PATHéP   i»  )ÚhttpÚhttpsÚDEFAULT_PORTSÚ_KTÚ_VTz, z,\s*T)Úaccept_encodingzaccept-encodingÚDEFAULT_ACCEPT_ENCODINGÚwin32ÚhostÚreturnÚboolc              	   C  sð   zdd l }W n
 ty   Y dS w z| |jd¡}t| |d¡d ƒ}| |d¡d }W n ttfy8   Y dS w |r=|s?dS | d¡}t	d |ƒ}|D ]*}|dkrXd| vrX d	S | 
dd
¡}| 
dd¡}| 
dd¡}t || tj¡ru d	S qKdS )Nr   Fz;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)r>   rG   ÚinternetSettingsÚproxyEnableÚproxyOverrideÚtest© rY   úK/var/www/html/CropPilot/venv/lib/python3.10/site-packages/requests/utils.pyÚproxy_bypass_registryc   s<   ÿþÿ

ÿr[   c                 C  s   t ƒ rt| ƒS t| ƒS )zšReturn True, if the host should be bypassed.

        Checks proxy settings gathered from the environment, if specified,
        or the registry.
        )r   r   r[   )r>   rY   rY   rZ   r   ‰   s   r   Údú6_t.SupportsItems[Any, Any] | Iterable[tuple[Any, Any]]úIterable[tuple[Any, Any]]c                 C  s   t | tƒr	|  ¡ S | S )z/Returns an internal sequence dictionary update.)Ú
isinstanceÚ_SupportsItemsÚitems)r\   rY   rY   rZ   Údict_to_sequence•   s   
rb   Úor   rK   c              	   C  s8  d }d}t st| tƒr|  d¡} t| dƒrt| ƒ}n2t| dƒr#| j}n)t| dƒrLz|  ¡ }W n tjt	fy:   Y nw t
 |¡j}d| jvrLt dt¡ t| dƒr�z|  ¡ }W n tyf   |d urd|}Y n)w t| d	ƒr�|d u r�z|  dd
¡ |  ¡ }|  |p€d¡ W n tyŽ   d}Y nw |d u r•d}td|| ƒS )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   r_   r    ÚencodeÚhasattrrf   rg   ÚioÚUnsupportedOperationÚAttributeErrorÚosÚfstatÚst_sizeÚmodeÚwarningsÚwarnr'   ri   rM   rj   Úmax)rc   Útotal_lengthÚcurrent_positionrg   rY   rY   rZ   Ú	super_len    sN   




ü
÷
€úÿrz   FÚurlú
_t.UriTypeÚraise_errorsútuple[str, str] | Nonec              	   C  s8  t | tƒr
|  d¡} tj d¡}|dur|f}ndd„ tD ƒ}zpddlm}m} d}|D ]}tj	 
|¡}tj	 |¡r>|} nq,|du rFW dS t| ƒ}	|	j}
|
du rTW dS z+||ƒ |
¡}|rxt|ƒr||d rhdnd}|| pod	|d
 ptd	fW W S W W dS W W dS  |tfy�   |r‹‚ Y W dS w  ttfy›   Y dS w )z;Returns the Requests tuple auth for a given url from netrc.rd   ÚNETRCNc                 s  s   � | ]}d |› �V  qdS )z~/NrY   )Ú.0ÚfrY   rY   rZ   Ú	<genexpr>ó   s   € z!get_netrc_auth.<locals>.<genexpr>r   )ÚNetrcParseErrorÚnetrcr   Ú rk   )r_   r   Údecoderq   ÚenvironÚgetr3   r„   rƒ   ÚpathÚ
expanduserÚexistsr"   ÚhostnameÚauthenticatorsÚanyrM   rH   rp   )r{   r}   Ú
netrc_fileÚnetrc_locationsrƒ   r„   Ú
netrc_pathr�   ÚlocÚrir>   r2   Úlogin_irY   rY   rZ   Úget_netrc_authç   sF   

þýÿýÿr•   Úobjú
str | Nonec                 C  sR   t | ddƒ}|r!t|ttfƒr#|d dkr%|d dkr'tj |¡S dS dS dS dS )z0Tries to guess the filename of the given object.ÚnameNr   ú<éÿÿÿÿú>)Úgetattrr_   r    r   rq   r‰   Úbasename)r–   r˜   rY   rY   rZ   Úguess_filename  s   *ÿrž   r‰   c              	   C  sæ   t j | ¡r| S t j | ¡\}}|r2t j |¡s2t j |¡\}}|s#nd ||g¡}|r2t j |¡rt |¡s9| S t |¡}|| ¡ vrF| S t j 	| d¡d ¡d }t
j|d�\}}zt  || |¡¡ W t  |¡ |S t  |¡ w )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š   )Úsuffix)rq   r‰   r‹   rO   ÚjoinÚzipfileÚ
is_zipfileÚZipFileÚnamelistÚsplitextÚtempfileÚmkstempÚwriteÚreadÚclose)r‰   ÚarchiveÚmemberÚprefixÚzip_filer    ÚfdÚextracted_pathrY   rY   rZ   Úextract_zipped_paths"  s*   ú


þr²   Úfilenameú%Generator[BufferedWriter, None, None]c                 c  sz   � t jtj | ¡d�\}}z"t |d¡�}|V  W d  ƒ n1 s"w   Y  t || ¡ W dS  ty<   t |¡ ‚ w )z-Write a file to the disk in an atomic fashion)ÚdirÚwbN)	r§   r¨   rq   r‰   ÚdirnameÚfdopenrQ   ÚBaseExceptionÚremove)r³   Útmp_descriptorÚtmp_nameÚtmp_handlerrY   rY   rZ   Úatomic_openH  s   €ÿ
þr¾   Úvalueú4Mapping[Any, Any] | Iterable[tuple[Any, Any]] | Noneúdict[Any, Any] | Nonec                 C  s.   | du rdS t | ttttfƒrtdƒ‚t| ƒS )a  Take 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)r_   r    r   r@   rK   rN   r   ©r¿   rY   rY   rZ   Úfrom_key_val_listU  s
   rÄ   ÚNonec                 C  ó   d S ©NrY   rÃ   rY   rY   rZ   Úto_key_val_listr  s   rÈ   ú6_t.SupportsItems[_KT, _VT] | Iterable[tuple[_KT, _VT]]úlist[tuple[_KT, _VT]]c                 C  rÆ   rÇ   rY   rÃ   rY   rY   rZ   rÈ   t  ó   ú=_t.SupportsItems[_KT, _VT] | Iterable[tuple[_KT, _VT]] | Noneúlist[tuple[_KT, _VT]] | Nonec                 C  sD   | du rdS t | ttttfƒrtdƒ‚t | tƒrt|  ¡ ƒS 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Â   )	r_   r    r   r@   rK   rN   r`   Úlistra   rÃ   rY   rY   rZ   rÈ   x  s   
ú	list[str]c                 C  sX   g }t | ƒD ]#}|dd… |dd…   krdkr$n nt|dd… ƒ}| |¡ q|S )a  Parse 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
    Nr   rš   ú")Ú_parse_list_headerÚunquote_header_valueÚappend)r¿   ÚresultÚitemrY   rY   rZ   Úparse_list_header˜  s   (rÖ   údict[str, str | None]c                 C  sx   i }t | ƒD ]3}d|vrd||< q| dd¡\}} | dd… | dd…   kr+dkr5n nt| dd… ƒ} | ||< q|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
    ú=Nr   rš   rÐ   )rÑ   rO   rÒ   )r¿   rÔ   rÕ   r˜   rY   rY   rZ   Úparse_dict_header¸  s   (
rÙ   Úis_filenamec                 C  s^   | r-| d | d   krdkr-n | S | dd… } |r#| dd… dkr-|   dd¡  d	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
    r   rš   rÐ   r   Nrk   z\\ú\z\")rQ   )r¿   rÚ   rY   rY   rZ   rÒ   Û  s   "÷rÒ   Úcjr,   c                 C  s   dd„ | D ƒ}|S )z€Returns a key/value dictionary from a CookieJar.

    :param cj: CookieJar object to extract cookies from.
    :rtype: dict
    c                 S  s   i | ]}|j |j“qS rY   )r˜   r¿   )r€   ÚcookierY   rY   rZ   Ú
<dictcomp>û  s    z'dict_from_cookiejar.<locals>.<dictcomp>rY   ©rÜ   Úcookie_dictrY   rY   rZ   Údict_from_cookiejarô  s   rá   rà   údict[str, str]c                 C  s
   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ß   rY   rY   rZ   Úadd_dict_to_cookiejarÿ  s   
rã   Úcontentc                 C  sT   t  dt¡ tjdtjd�}tjdtjd�}t d¡}| | ¡| | ¡ | | ¡ S )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=["\']*(.+?)["\'>])ru   rv   ÚDeprecationWarningrR   ÚcompilerT   Úfindall)rä   Ú
charset_reÚ	pragma_reÚxml_rerY   rY   rZ   Úget_encodings_from_content
  s   ú	
ÿþÿrì   Úheaderútuple[str, dict[str, Any]]c           
      C  s�   |   d¡}|d  ¡ |dd… }}i }d}|D ]+}| ¡ }|rC| d¡ }dkrC|d|…  |¡}||d d…  |¡}	|	|| ¡ < q||fS )z¨Returns content type and parameters from given header.

    :param header: string
    :return: tuple containing content type and dictionary of
         parameters.
    rC   r   r   Nz"' rØ   rš   )rO   ÚstripÚfindÚlower)
rí   ÚtokensÚcontent_typeÚparamsÚparams_dictÚstrip_charsÚparamÚidxÚkeyr¿   rY   rY   rZ   Ú_parse_content_type_header#  s   
€rú   ÚheadersúCaseInsensitiveDict[str]c                 C  sP   |   d¡}|s	dS t|ƒ\}}d|v r|d  d¡S d|v r dS d|v r&dS dS )	z}Returns encodings from given HTTP Header Dict.

    :param headers: dictionary to extract encoding from.
    :rtype: str
    zcontent-typeNÚcharsetz'"Útextz
ISO-8859-1zapplication/jsonrd   )rˆ   rú   rï   )rû   ró   rô   rY   rY   rZ   Úget_encoding_from_headers9  s   
þrÿ   ÚiteratorúIterable[bytes]Úrr1   ú"Generator[str | bytes, None, None]c                 c  sj   � |j du r| E dH  dS t |j ¡dd�}| D ]}| |¡}|r$|V  q|jddd�}|r3|V  dS dS )zStream decodes an iterator.NrQ   ©Úerrorsó    T)Úfinal)ÚencodingÚcodecsÚgetincrementaldecoderr†   )r   r  ÚdecoderÚchunkÚrvrY   rY   rZ   Ústream_decode_response_unicodeR  s   €


€
ÿr  Ústringr   Úslice_lengthú
int | NoneúGenerator[bytes, None, None]c                 C  rÆ   rÇ   rY   ©r  r  rY   rY   rZ   Úiter_slicese  rË   r  úGenerator[str, None, None]c                 C  rÆ   rÇ   rY   r  rY   rY   rZ   r  i  rË   úbytes | strú"Generator[bytes | str, None, None]c                 c  sX   � d}|du s|dkrt | ƒ}|t | ƒk r*| ||| … V  ||7 }|t | ƒk sdS dS )z Iterate over slices of a string.r   N)rf   )r  r  ÚposrY   rY   rZ   r  m  s   €þústr | bytes | Nonec                 C  sˆ   t  dt¡ | jdu rdS g }t| jƒ}|r,zt| j|ƒW S  ty+   | |¡ Y nw zt| j|p3ddd�W S  t	yC   | j Y S w )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.)Nrd   rQ   r  )
ru   rv   ræ   rä   rÿ   rû   r    ÚUnicodeErrorrÓ   Ú	TypeError)r  Útried_encodingsr  rY   rY   rZ   Úget_unicode_from_responsey  s&   ú

ÿ
ÿr  zBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~ÚUNRESERVED_SETÚuric              	   C  sÆ   |   d¡}tdt|ƒƒD ]Q}|| dd… }t|ƒdkrT| ¡ rTz	tt|dƒƒ}W n ty8   td|› d�ƒ‚w |tv rJ||| dd…  ||< qd|| › �||< qd|| › �||< qd	 	|¡S )
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
    ú%r   r   rk   é   z"Invalid percent-escape sequence: 'ú'Nr…   )
rO   Úrangerf   ÚisalnumÚchrrK   rN   r)   r  r¡   )r  ÚpartsÚiÚhÚcrY   rY   rZ   Úunquote_unreserved¨  s   
ÿ
r*  c                 C  s:   d}d}z	t t| ƒ|d�W S  ty   t | |d� Y S w )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)r   r*  r)   )r  Úsafe_with_percentÚsafe_without_percentrY   rY   rZ   Úrequote_uriÀ  s   ür.  ÚipÚnetc                 C  sl   t  dt | ¡¡d }| d¡\}}t  dt tt|ƒƒ¡¡d }t  dt |¡¡d |@ }||@ ||@ k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=Lr   rŸ   )ÚstructÚunpackÚsocketÚ	inet_atonrO   Údotted_netmaskrK   )r/  r0  ÚipaddrÚnetaddrÚbitsÚnetmaskÚnetworkrY   rY   rZ   Úaddress_in_networkÖ  s
   r;  Úmaskc                 C  s&   ddd|  > d A }t  t d|¡¡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)r3  Ú	inet_ntoar1  Úpack)r<  r8  rY   rY   rZ   r5  å  s   r5  Ú	string_ipc                 C  s&   zt  | ¡ W dS  ty   Y dS w )z
    :rtype: bool
    FT)r3  r4  rM   )r@  rY   rY   rZ   Úis_ipv4_addressð  s   þÿrA  Ústring_networkc                 C  s‚   |   d¡dkr?zt|  d¡d ƒ}W n
 ty   Y dS w |dk s%|dkr'dS zt |  d¡d ¡ W dS  ty>   Y dS w dS )zV
    Very simple check of the cidr format in no_proxy variable.

    :rtype: bool
    rŸ   r   Fr=  r   T)ÚcountrK   rO   rN   r3  r4  rM   )rB  r<  rY   rY   rZ   Úis_valid_cidrû  s   ÿüÿrD  Úenv_nameúGenerator[None, None, None]c              	   c  s~   � |du}d}|rt j | ¡}|t j| < zdV  W |r,|du r%t j| = dS |t j| < dS dS |r>|du r9t j| = w |t j| < 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)rq   r‡   rˆ   )rE  r¿   Úvalue_changedÚ	old_valuerY   rY   rZ   Úset_environ  s    €
ürI  Úno_proxyc              
   C  sZ  ddd„}|}|du r|dƒ}t | ƒ}|j}|du rd	S |r}d
d„ | dd¡ d¡D ƒ}t|ƒrJ|D ]}t|ƒrAt||ƒr@ d	S q2||krH d	S q2n3|}|jrW|d|j› �7 }|D ]#}	|	 d¡}	||	ksh||	krk d	S d|	 }	| 	|	¡sy| 	|	¡r| d	S qYt
d|ƒ� zt|ƒ}
W n ttjfy—   d}
Y nw W d  ƒ n1 s¢w   Y  |
r«d	S dS )zL
    Returns whether we should bypass proxies or not.

    :rtype: bool
    rù   r    r?   r—   c                 S  s   t j | ¡pt j |  ¡ ¡S rÇ   )rq   r‡   rˆ   Úupper)rù   rY   rY   rZ   Ú	get_proxy3  s   z(should_bypass_proxies.<locals>.get_proxyNrJ  Tc                 s  s   � | ]}|r|V  qd S rÇ   rY   )r€   r>   rY   rY   rZ   r‚   E  s   € z(should_bypass_proxies.<locals>.<genexpr>ú r…   ú,ú:rD   F)rù   r    r?   r—   )r"   rŒ   rQ   rO   rA  rD  r;  ÚportÚlstripÚendswithrI  r   r  r3  Úgaierror)r{   rJ  rL  Úno_proxy_argÚparsedrŒ   Úno_proxy_hostsÚproxy_ipÚhost_with_portr>   ÚbypassrY   rY   rZ   Úshould_bypass_proxies*  sT   
	
ÿýü	
ÿÿ€ýrZ  c                 C  s   t | |d�ri S tƒ S )zA
    Return a dict of environment proxies.

    :rtype: dict
    ©rJ  )rZ  r   )r{   rJ  rY   rY   rZ   Úget_environ_proxiesi  s   r\  Úproxiesúdict[str, str] | Nonec                 C  sv   |pi }t | ƒ}|jdu r| |j| d¡¡S |jd |j |jd|j dg}d}|D ]}||v r8|| } |S q+|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://zall://)r"   rŒ   rˆ   Úscheme)r{   r]  ÚurlpartsÚ
proxy_keysÚproxyÚ	proxy_keyrY   rY   rZ   Úselect_proxyu  s"   
üüre  ÚrequestúRequest | PreparedRequestÚ	trust_envc           	      C  sz   |dur|ni }t t| jƒ}t|ƒj}| d¡}| ¡ }|r;t||d�s;t||d�}| || d¡¡}|r;| 	||¡ |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
    NrJ  r[  r_  )
r
   r    r{   r"   r`  rˆ   ÚcopyrZ  r\  Ú
setdefault)	rf  r]  rh  r{   r`  rJ  Únew_proxiesÚenviron_proxiesrc  rY   rY   rZ   Úresolve_proxies�  s   

rm  úpython-requestsr˜   c                 C  s   | › dt › �S )zO
    Return a string representing the default user agent.

    :rtype: str
    rŸ   r   )r˜   rY   rY   rZ   Údefault_user_agent®  s   ro  c                   C  s   t tƒ tdddœƒS )z9
    :rtype: requests.structures.CaseInsensitiveDict
    z*/*z
keep-alive)z
User-AgentzAccept-EncodingÚAcceptÚ
Connection)r+   ro  r<   rY   rY   rY   rZ   Údefault_headers·  s   üÿrr  úlist[dict[str, str]]c           	   
   C  sÆ   g }d}|   |¡} | s|S t d| ¡D ]M}z
| dd¡\}}W n ty-   |d}}Y nw d|  d¡i}| d¡D ] }z	| d¡\}} W n
 tyO   Y  nw |   |¡||  |¡< q:| |¡ q|S )	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, *<rC   r   r…   r{   z<> '"rØ   )rï   rR   rO   rN   rÓ   )	r¿   ÚlinksÚreplace_charsÚvalr{   rô   Úlinkr÷   rù   rY   rY   rZ   Úparse_header_linksÅ  s*   
ÿÿrx  ú Úasciirk   é   Údatac                 C  sÐ   | dd… }|t jt jfv rdS |dd… t jkrdS |dd… t jt jfv r)dS | t¡}|dkr4d	S |dkrN|ddd… tkrCd
S |ddd… tkrNdS |dkrf|dd… t	kr\dS |dd… t	krfdS dS )z
    :rtype: str
    Né   zutf-32r{  z	utf-8-sigrk   zutf-16r   rd   z	utf-16-ber   z	utf-16-lez	utf-32-bez	utf-32-le)
r	  ÚBOM_UTF32_LEÚBOM_UTF32_BEÚBOM_UTF8ÚBOM_UTF16_LEÚBOM_UTF16_BErC  Ú_nullÚ_null2Ú_null3)r|  ÚsampleÚ	nullcountrY   rY   rZ   Úguess_json_utfð  s*   
rˆ  Ú
new_schemec                 C  sv   t | ƒ}|\}}}}}}}	|j}
|
s||
}
}|r%tt|
ƒ}
d ||
g¡}
|du r+|}|du r1d}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
    ú@Nr…   )r   Únetlocr
   r    r¡   r#   )r{   r‰  rU  r`  ÚauthÚ_hostÚ_portr‰   ÚqueryÚfragmentr‹  rY   rY   rZ   Úprepend_scheme_if_needed  s   

r‘  útuple[str, str]c              	   C  s@   t | ƒ}zt|jƒt|jƒf}W |S  ttfy   d}Y |S w )z{Given a url with authentication components, extract them into a tuple of
    username,password.

    :rtype: (str,str)
    )r…   r…   )r"   r!   ÚusernameÚpasswordrp   r  )r{   rU  rŒ  rY   rY   rZ   Úget_auth_from_url.  s   ýýr•  útuple[str | bytes, str | bytes]c                 C  s$   | \}}t | |dƒ t | |dƒ dS )z§Verifies that header parts don't contain leading whitespace
    reserved characters, or return characters.

    :param header: tuple, in the format (name, value).
    r   r   N)Ú_validate_header_part)rí   r˜   r¿   rY   rY   rZ   Úcheck_header_validity?  s   r˜  Úheader_partústr | bytesÚheader_validator_indexc                 C  sx   t |tƒr
t| }nt |tƒrt| }ntd|›d| › dt|ƒ› �ƒ‚| |¡s:|dkr.dnd}td|› d|›�ƒ‚d S )	NzHeader part (z) from z# must be of type str or bytes, not r   r˜   r¿   zTInvalid leading whitespace, reserved character(s), or return character(s) in header z: )r_   r    r   r   r   r(   ÚtyperS   )rí   r™  r›  Ú	validatorÚheader_kindrY   rY   rZ   r—  J  s&   



ÿÿ
ÿÿÿþr—  c                 C  sF   t | ƒ\}}}}}}|s||}}| dd¡d }t|||||dfƒS )zW
    Given a url remove the fragment and the authentication part.

    :rtype: str
    rŠ  r   rš   r…   )r"   Úrsplitr#   )r{   r`  r‹  r‰   rô   r�  Ú	_fragmentrY   rY   rZ   Úurldefragauthb  s
   
r¡  Úprepared_requestr/   c                 C  sR   t | jddƒ}|dur%t| jtƒr%z|| jƒ W dS  ty$   tdƒ‚w tdƒ‚)zfMove file pointer back to its recorded starting position
    so it can be read again on redirect.
    rj   Nz;An error occurred when rewinding request body for redirect.z+Unable to rewind request body for redirect.)rœ   Úbodyr_   Ú_body_positionr   rM   r*   )r¢  Ú	body_seekrY   rY   rZ   Úrewind_bodys  s   
þÿÿr¦  )r>   r    r?   r@   )r\   r]   r?   r^   )rc   r   r?   rK   )F)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Ê   )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    r?   rÏ   )rí   r    r?   rî   )rû   rü   r?   r—   )r   r  r  r1   r?   r  )r  r   r  r  r?   r  )r  r    r  r  r?   r  )r  r  r  r  r?   r  )r  r1   r?   r  )r  r    r?   r    )r/  r    r0  r    r?   r@   )r<  rK   r?   r    )r@  r    r?   r@   )rB  r    r?   r@   )rE  r    r¿   r—   r?   rF  )r{   r    rJ  r—   r?   r@   rÇ   )r{   r    rJ  r—   r?   râ   )r{   r    r]  r^  r?   r—   )T)rf  rg  r]  r^  rh  r@   r?   râ   )rn  )r˜   r    r?   r    )r?   rü   )r¿   r    r?   rs  )r|  r   r?   r—   )r{   r    r‰  r    r?   r    )r{   r    r?   r’  )rí   r–  r?   rÅ   )rí   r–  r™  rš  r›  rK   r?   rÅ   )r{   r    r?   r    )r¢  r/   r?   rÅ   )„Ú__doc__Ú
__future__r   r	  Ú
contextlibrn   rq   rR   r3  r1  Úsysr§   ru   r¢   Úcollectionsr   Úcollections.abcr   r   Útypingr   r   r   r	   r
   r   Úurllib3.utilr   r   r…   r   r   Ú_internal_utilsr   r   r   r   r.   r   r`   Úcompatr   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   rÑ   Úcookiesr&   Ú
exceptionsr'   r(   r)   r*   Ú
structuresr+   Úhttp.cookiejarr,   r-   Ú_tÚmodelsr/   r0   r1   r3   Ú__annotations__Úwherer4   r8   r9   r:   r¡   rO   r<   Úplatformr[   rb   rz   r•   rž   r²   Úcontextmanagerr¾   rÄ   rÈ   rÖ   rÙ   rÒ   rá   rã   rì   rú   rÿ   r  r  r  Ú	frozensetr  r*  r.  r;  r5  rA  rD  rI  rZ  r\  re  rm  ro  rr  rx  rl   rƒ  r„  r…  rˆ  r‘  r•  r˜  r—  r¡  r¦  rY   rY   rY   rZ   Ú<module>   sÈ     	<ÿ

&

Hÿ
4
&


 
 #







*ÿ






?
ý
	

&

 