
    /h؁                     ^   d 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 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 ddlm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z& ddl'm(Z( ddl)m*Z*m+Z+m,Z,m-Z- ddl.m/Z/ dZ0 ej1                    Z2dddZ3d4                     ej5        d ed          d                             Z6ej7        dk    rd Z8d Z d Z9d Z:dJdZ;d Z<d  Z=ej>        d!             Z?d" Z@d# ZAd$ ZBd% ZCdJd&ZDd' ZEd( ZFd) ZGd* ZHd+ ZId, ZJd- ZKd. ZL eMd/          ZNd0 ZOd1 ZPd2 ZQd3 ZRd4 ZSd5 ZTej>        d6             ZUd7 ZVdKd8ZWd9 ZXdLd:ZYdMd<ZZd= Z[d> Z\d?]                    d@          Z^e^dAz  Z_e^dBz  Z`dC ZadD ZbdE ZcdF ZddG ZedH ZfdI ZgdS )Nz
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to_native_string)Mapping
basestringbytes
getproxiesgetproxies_environmentinteger_types)parse_http_list)proxy_bypassproxy_bypass_environmentquotestrunquoteurlparse
urlunparsecookiejar_from_dict)FileModeWarningInvalidHeader
InvalidURLUnrewindableBodyError)CaseInsensitiveDict)z.netrc_netrcP   i  )httphttpsz, z,\s*T)accept_encodingzaccept-encodingwin32c                 L   	 dd l }n# t          $ r Y dS w xY w	 |                    |j        d          }t	          |                    |d          d                   }|                    |d          d         }n# t          t          f$ r Y dS w xY w|r|sdS |                    d          }|D ]t}|dk    rd| vr d	S |	                    dd
          }|	                    dd          }|	                    dd          }t          j        || t          j                  r d	S ud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replacerematchI)hostr.   internetSettingsproxyEnableproxyOverridetests         M/var/www/html/venv/lib/python3.11/site-packages/pip/_vendor/requests/utils.pyproxy_bypass_registryrA   G   sv   	MMMM 	 	 	55	
	%~~(N   
 f112BMRRSTUVVK"//0@/RRSTUMM$ 	 	 	55	 	- 	5
 &++C00! 	 	Dy  d??44<<U++D<<U++D<<T**DxdBD)) ttus    
A A: :BBc                 Z    t                      rt          |           S t          |           S )zReturn True, if the host should be bypassed.

        Checks proxy settings gathered from the environment, if specified,
        or the registry.
        )r   r   rA   )r;   s    r@   r   r   k   s.     "## 	/+D111(...    c                 N    t          | d          r|                                 } | S )z/Returns an internal sequence dictionary update.items)hasattrrE   )ds    r@   dict_to_sequencerH   w   s(     q' GGIIHrC   c                    d }d}t          | d          rt          |           }nt          | d          r| j        }n~t          | d          rn	 |                                 }t          j        |          j        }d| j        vrt          j        dt                     n# t          j        t          f$ r Y nw xY wt          | d          r	 |                                 }t          | d          rW|U	 |                     dd	           |                                 }|                     |pd           n'# t          $ r d}Y nw xY wn# t          $ r ||}Y nw xY w|d}t!          d||z
            S )
Nr   __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   )rF   rK   rL   osfstatst_sizemodewarningswarnr   ioUnsupportedOperationAttributeErrorrN   rO   r4   max)ototal_lengthcurrent_positionrL   s       r@   	super_lenr^      s   Lq) 1vv	E		 u	H		 	XXZZF 8F++3L !&  2 $
 
 
 '8 	 	 	 D		. q& %	% vvxx q&!! %l&:	%FF1aLLL#$6688L FF+0q1111 % % %#$LLL%%  	0 	0 	0
 '#/ 	0* q,!11222s7   B B87B8E 3AD5 5EEEEFc                    t           j                            d          }||f}nd t          D             }	 ddlm}m} d}|D ]X}	 t           j                            |          }n# t          $ r Y  dS w xY wt           j        	                    |          r|} nY|dS t          |           }	d}
t          | t                    r|
                    d          }
|	j                            |
          d         }	  ||                              |          }|r|d         rdnd}||         |d	         fS dS # |t"          f$ r |r Y dS w xY w# t$          t&          f$ r Y dS w xY w)
z;Returns the Requests tuple auth for a given url from netrc.NETRCNc              3       K   | ]	}d | V  
dS )z~/N ).0fs     r@   	<genexpr>z!get_netrc_auth.<locals>.<genexpr>   s(      99888999999rC   r   )NetrcParseErrornetrc   :asciir   rP   )rQ   environgetNETRC_FILESrg   rf   path
expanduserKeyErrorexistsr   
isinstancer   decodenetlocr6   authenticatorsr4   r/   rY   )urlraise_errors
netrc_filenetrc_locationsrf   rg   
netrc_pathrd   locrisplitstrr;   r!   login_is                 r@   get_netrc_authr~      s    ((J%-99[999-00000000
  	 	Ag((++    	 w~~c""  

 Fc]] c3 	0w//Hyx((+
	U:&&55d;;F 4%ay/!!aw334 4  ) 	 	 	    	 (   sZ   E A'&E '
A61E 5A66)E !AE =;D; ;E
E EE E&%E&c                     t          | dd          }|rLt          |t                    r9|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   <>)getattrrq   r   rQ   rm   basename)objr   s     r@   guess_filenamer      sw    3%%D &
4,, &aCDHPSOOw%%%& & & &OOrC   c                    t           j                            |           r| S t           j                            |           \  }}|r|t           j                            |          s]t           j                            |          \  }}|sn8d                    ||g          }|rt           j                            |          ]t          j        |          s| S t          j        |          }||                                vr| S t          j
                    }t           j                            ||                    d          d                   }t           j                            |          sOt          |          5 }|                    |                    |                     ddd           n# 1 swxY w Y   |S )zReplace 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)rQ   rm   rp   r6   joinzipfile
is_zipfileZipFilenamelisttempfile
gettempdiratomic_openwriteread)rm   archivememberprefixzip_filetmpextracted_pathfile_handlers           r@   extract_zipped_pathsr     s   
 
w~~d  gmmD))OGV
 ,"'..11 ,'--00 	 66*++  ,"'..11 , g&& w''HX&&(((( 


CW\\#v||C'8'8'<==N7>>.)) 6(( 	6Lx}}V44555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6s   >)F33F7:F7c              #   H  K   t          j        t          j                            |                     \  }}	 t          j        |d          5 }|V  ddd           n# 1 swxY w Y   t          j        ||            dS # t          $ r t          j        |            w xY w)z-Write a file to the disk in an atomic fashion)dirwbN)	r   mkstemprQ   rm   dirnamefdopenr7   BaseExceptionremove)filenametmp_descriptortmp_nametmp_handlers       r@   r   r   '  s        (/BGOOH4M4MNNNNHY~t,, 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	

8X&&&&&   
	(s/   B AB A##B &A#'B  B!c                     | 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)rq   r   r   boolr2   r5   r   values    r@   from_key_val_listr   4  sG    $ }t%#udC011 HFGGGurC   c                     | dS t          | t          t          t          t          f          rt          d          t          | t                    r|                                 } 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   )	rq   r   r   r   r2   r5   r   rE   listr   s    r@   to_key_val_listr   O  sd    " }t%#udC011 HFGGG%!! ;;rC   c                     g }t          |           D ]N}|dd         |dd         cxk    rdk    rn nt          |dd                   }|                    |           O|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items      r@   parse_list_headerr   m  s    . F"5))  8tBCCy''''C''''''QrT
33DdMrC   c                     i }t          |           D ]a}d|vrd||<   |                    dd          \  }} | dd         | dd         cxk    rdk    rn nt          | dd                   } | ||<   b|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   r6   r   )r   r   r   r   s       r@   parse_dict_headerr     s    , F"5))  d??F4Ljja((e!9bcc
))))c)))))(qt55EtMrC   c                     | r`| d         | d         cxk    rdk    rGn nD| dd         } |r| dd         dk    r*|                      dd                               d	d          S | S )
zUnquotes 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   NrP   z\\\z\")r7   )r   is_filenames     r@   r   r     s      CqU2Y----#-----
 ad  	CeBQBi611==..66ucBBBLrC   c                 2    i }| D ]}|j         ||j        <   |S )zReturns a key/value dictionary from a CookieJar.

    :param cj: CookieJar object to extract cookies from.
    :rtype: dict
    )r   r   )cjcookie_dictcookies      r@   dict_from_cookiejarr     s/     K 0 0#)<FK  rC   c                 "    t          ||           S )zReturns 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     r@   add_dict_to_cookiejarr     s     {B///rC   c                 `   t          j        dt                     t          j        dt          j                  }t          j        dt          j                  }t          j        d          }|                    |           |                    |           z   |                    |           z   S )zlReturns encodings from given content string.

    :param content: bytestring to extract encodings from.
    zIn 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   DeprecationWarningr8   compiler:   findall)content
charset_re	pragma_rexml_res       r@   get_encodings_from_contentr     s    
 M1 	   @MMMJ
IQSQUVVVIZ?@@F 	7##


G
$
$	%
..
!
!	"rC   c                    |                      d          }|d                                         |dd         }}i }d}|D ]}|                                }|rs|d}}|                    d          }	|	dk    r=|d|	                             |          }||	dz   d                             |          }|||                                <   ||fS )	zReturns content type and parameters from given header

    :param header: string
    :return: tuple containing content type and dictionary of
         parameters
    r*   r   r   Nz"' Tr   r   )r6   stripfindlower)
headertokenscontent_typeparamsparams_dictitems_to_stripparamkeyr   index_of_equalss
             r@   _parse_content_type_headerr     s     \\#F!!9??,,fQRRj&LKN - - 	-C#jjooO"$$,_,-33NCCo1334::>JJ',K		$$$rC   c                     |                      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/jsonutf-8)rk   r   r   )headersr   r   s      r@   get_encoding_from_headersr     s     ;;~..L t5lCCL&Fi &&u---|\))w *)rC   c              #      K   |j         
| E d{V  dS  t          j        |j                   d          }| D ]}|                    |          }|r|V  |                    dd          }|r|V  dS dS )zStream decodes an iterator.Nr7   errorsrC   T)final)encodingcodecsgetincrementaldecoderrr   )iteratorrdecoderchunkrvs        r@   stream_decode_response_unicoder   .  s       	z6f*1:66iHHHG  ^^E"" 	HHH	4	(	(B	  rC   c              #      K   d}||dk    rt          |           }|t          |           k     r)| |||z            V  ||z  }|t          |           k     'dS dS )z Iterate over slices of a string.r   N)rK   )stringslice_lengthposs      r@   iter_slicesr   ?  s{      
C|q006{{
F

S3--....| F





rC   c                 :   t          j        dt                     g }t          | j                  }|r;	 t          | j        |          S # t          $ r |                    |           Y nw xY w	 t          | j        |d          S # t          $ r
 | j        cY S w xY w)zReturns 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
    zIn 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.)r7   r   )
rU   rV   r   r   r   r   r   UnicodeErrorr   	TypeError)r   tried_encodingsr   s      r@   get_unicode_from_responser   I  s     M1 	   O )33H -	-qy(+++ 	- 	- 	-""8,,,,,	-19hy9999   ys#   A	 	A+*A+/B BBzBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~c                    |                      d          }t          dt          |                    D ]}||         dd         }t          |          dk    r|                                ro	 t	          t          |d                    }n!# t          $ r t          d| d          w xY w|t          v r|||         dd         z   ||<   d||          ||<   d||          ||<   d		                    |          S )
zUn-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   rP      z"Invalid percent-escape sequence: ''N )
r6   rangerK   isalnumchrr2   r5   r   UNRESERVED_SETr   )uripartsihcs        r@   unquote_unreservedr	  v  s    IIcNNE1c%jj!! & &!HQqSMq66Q;;199;;;LAr

OO L L L !Ja!J!J!JKKKL N""uQx|+a)uQx>>a%58~~E!HH775>>s   -BB)c                     d}d}	 t          t          |           |          S # t          $ r t          | |          cY S w xY w)zRe-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_percents      r@   requote_urir    sk     /0	5 ',,3DEEEE 5 5 5 S3444444	5s   $ AAc           
         t          j        dt          j        |                     d         }|                    d          \  }}t          j        dt          j        t          t          |                                        d         }t          j        dt          j        |                    d         |z  }||z  ||z  k    S )zThis 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_atonr6   dotted_netmaskr2   )ipnetipaddrnetaddrbitsnetmasknetworks          r@   address_in_networkr    s     ]4!1"!5!566q9FIIcNNMGTmD&"2>#d))3L3L"M"MNNqQGmD&"27";";<<Q?'IGW'G"344rC   c                 l    ddd| z
  z  dz
  z  }t          j        t          j        d|                    S )zConverts 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)maskr  s     r@   r  r    s8     b4i1,,DFKd33444rC   c                 T    	 t          j        |            n# t          $ r Y dS w xY wdS )z
    :rtype: bool
    FT)r  r  r4   )	string_ips    r@   is_ipv4_addressr$    sB    ####   uu4s    
%%c                 N   |                      d          dk    r	 t          |                     d          d                   }n# t          $ r Y dS w xY w|dk     s|dk    rdS 	 t	          j        |                     d          d                    n# t          $ r Y dS w xY wdS dS )zV
    Very simple check of the cidr format in no_proxy variable.

    :rtype: bool
    r   r   Fr  r   T)countr2   r6   r5   r  r  r4   )string_networkr!  s     r@   is_valid_cidrr(    s     C  A%%	~++C00344DD 	 	 	55	 !88tbyy5	^11#66q9:::: 	 	 	55	 u4s#   (A 
AA$-B 
B B c              #     K   |du}|r.t           j                            |           }|t           j        | <   	 dV  |r"|t           j        | = dS |t           j        | <   dS dS # |r|t           j        | = n|t           j        | <   w xY w)zSet 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   rj   rk   )env_namer   value_changed	old_values       r@   set_environr-    s       %M %JNN8,,	$
81 	1 Jx((('0
8$$$		1 	1= 	1 Jx(('0
8$0000s   A" "#Bc                    d }|}| |d          }t          |           }|j        dS |rd |                    dd                              d          D             }t	          |j                  r<|D ]8}t          |          rt          |j        |          r dS *|j        |k    r dS 9nR|j        }|j        r|d	|j         z  }|D ]4}|j                            |          s|                    |          r dS 5t          d|          5  	 t          |j                  }n# t          t          j        f$ r d
}Y nw xY wddd           n# 1 swxY w Y   |rdS d
S )zL
    Returns whether we should bypass proxies or not.

    :rtype: bool
    c                     t           j                            |           p0t           j                            |                                           S N)rQ   rj   rk   upper)r   s    r@   	get_proxyz(should_bypass_proxies.<locals>.get_proxy  s1    z~~c""AbjnnSYY[[&A&AArC   Nno_proxyTc              3      K   | ]}||V  	d S r0  rb   )rc   r;   s     r@   re   z(should_bypass_proxies.<locals>.<genexpr>  s'      RRTTRDRRRRRRrC    r   ,:F)r   hostnamer7   r6   r$  r(  r  portendswithr-  r   r   r  gaierror)	ru   r3  r2  no_proxy_argparsedproxy_iphost_with_portr;   bypasss	            r@   should_bypass_proxiesrA    s#   B B B
 L9Z((c]]Ft   SRX%5%5c2%>%>%D%DS%I%IRRR6?++ 	 $     **  )&/8DD $#tt$_00  44 1	  $_N{ 4"3fk"3"33     ?++D11  ^5L5LT5R5R    44 
 
Z	.	.  	!&/22FF6?+ 	 	 	FFF		                t5s6   ED)(E)EEEEEEc                 D    t          | |          ri S t                      S )zA
    Return a dict of environment proxies.

    :rtype: dict
    r3  )rA  r   )ru   r3  s     r@   get_environ_proxiesrD  3  s(     S8444 	||rC   c                    |pi }t          |           }|j        .|                    |j        |                    d                    S |j        dz   |j        z   |j        d|j        z   dg}d}|D ]}||v r
||         } n|S )zSelect 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   r8  rk   scheme)ru   proxiesurlparts
proxy_keysproxy	proxy_keys         r@   select_proxyrM  ?  s     mG}}H {{8?GKK,>,>??? 	%("338$$	J E  	I&EE   LrC   c                 d   ||ni }| j         }t          |          j        }|                    d          }|                                }|rct          ||          sRt          ||          }|                    ||                    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 a 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
    Nr3  rC  rF  )ru   r   rG  rk   copyrA  rD  
setdefault)	requestrH  	trust_envru   rG  r3  new_proxiesenviron_proxiesrK  s	            r@   resolve_proxiesrU  Y  s     !,gg"G
+Cc]]!F{{:&&H,,..K 2.sXFFF 2-cHEEE##FO,?,?,F,FGG 	2""65111rC   python-requestsc                     |  dt            S )zO
    Return a string representing the default user agent.

    :rtype: str
    r   r   )r   s    r@   default_user_agentrX  t  s     ""["""rC   c                  L    t          t                      t          ddd          S )z9
    :rtype: requests.structures.CaseInsensitiveDict
    z*/*z
keep-alive)z
User-AgentzAccept-EncodingAccept
Connection)r    rX  DEFAULT_ACCEPT_ENCODINGrb   rC   r@   default_headersr]  }  s2     ,..6&		
 	
  rC   c                    g }d}|                      |          } | s|S t          j        d|           D ]}	 |                    dd          \  }}n# t          $ r |d}}Y nw xY wd|                     d          i}|                    d          D ]X}	 |                    d          \  }} n# t          $ r Y  n0w xY w|                      |          ||                     |          <   Y|                    |           |S )	zReturn 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*   r   r   ru   z<> '"r   )r   r8   r6   r5   r   )	r   linksreplace_charsvalru   r   linkr   r   s	            r@   parse_header_linksrc    sA    EMKK&&E x&&  	"))C++KC 	" 	" 	"rCCC	" syy**+\\#&& 	H 	HE"[[--
UU    .3[[-G-GD=))**TLs#   AA! A!B,,
B:9B: ri   rP      c                    | 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    rd	S |dk    r,|ddd         t          k    rd
S |ddd         t          k    rdS |dk    r*|dd         t          k    rdS |dd         t          k    rdS dS )z
    :rtype: str
    N   zutf-32re  z	utf-8-sigrP   zutf-16r   r   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_BEr&  _null_null2_null3)datasample	nullcounts      r@   guess_json_utfrs    s    "1"XF&%v':;;;xbqbzV_$${bqbzf)6+>???xU##IA~~wA~~##A#;&  ;!$Q$<6!!;A~~"1":;!"":;4rC   c                     t          |           }|\  }}}}}}}	|j        }
|
s||
}}
|rd                    ||
g          }
||}|d}t          ||
|d||	f          S )zGiven 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   rs   r   r   )ru   
new_schemer=  rG  authr;   r9  rm   queryfragmentrs   s              r@   prepend_scheme_if_neededrz    s     s^^F6<3FD$dE8 ]F $V * 4.))~|vvtRABBBrC   c                     t          |           }	 t          |j                  t          |j                  f}n# t          t
          f$ r d}Y nw xY w|S )z{Given a url with authentication components, extract them into a tuple of
    username,password.

    :rtype: (str,str)
    )r   r   )r   r   usernamepasswordrY   r   )ru   r=  rw  s      r@   get_auth_from_urlr~    sd     c]]F(('&/*B*BCI&    Ks   (: AAc                 R   | \  }}| D ]@}t          |          t          vr(t          d|d|d|dt          |                     At          |dt          t          |                   d                    t          |dt          t          |                   d                    d	S )
zVerifies that header parts don't contain leading whitespace
    reserved characters, or return characters.

    :param header: tuple, in the format (name, value).
    zHeader part (z) from {: z$} must be of type str or bytes, not r   r   r   r   N)typer
   r   _validate_header_part)r   r   r   parts       r@   check_header_validityr    s     KD%  ::...: : : : :5 : :-1$ZZ: :   / $(9$t**(Ea(HIII%*;DKK*H*KLLLLLrC   c                 Z    |                     |           st          d| d|           d S )NzSInvalid leading whitespace, reserved character(s), or returncharacter(s) in header r  )r9   r   )header_partheader_kind	validators      r@   r  r    sV    ??;'' 
E&1E E5@E E
 
 	

 
rC   c                     t          |           \  }}}}}}|s||}}|                    dd          d         }t          |||||df          S )zW
    Given a url remove the fragment and the authentication part.

    :rtype: str
    ru  r   r   r   )r   rsplitr   )ru   rG  rs   rm   r   rx  ry  s          r@   urldefragauthr    sb     5=SMM1FFD&%  $V]]3""2&FvvtVUB?@@@rC   c                     t          | j        dd          }|Jt          | j        t                    r0	  || j                   dS # t
          $ r t          d          w xY wt          d          )zfMove file pointer back to its recorded starting position
    so it can be read again on redirect.
    rO   Nz;An error occurred when rewinding request body for redirect.z+Unable to rewind request body for redirect.)r   bodyrq   _body_positionr   r4   r   )prepared_request	body_seeks     r@   rewind_bodyr  /  s     (-vt<<I'" "	I&566666 	 	 	'M  	
 $$QRRRs   A A )Fr0  )T)rV  )h__doc__r   
contextlibrW   rQ   r8   r  r  sysr   rU   r   collectionsr   pip._vendor.urllib3.utilr   r   r   r   r	   _internal_utilsr
   r   compatr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   cookiesr   
exceptionsr   r   r   r   
structuresr    rl   whereDEFAULT_CA_BUNDLE_PATHDEFAULT_PORTSr   r6   r\  platformrA   rH   r^   r~   r   r   contextmanagerr   r   r   r   r   r   r   r   r   r   r   r   r   r   	frozensetr  r	  r  r  r  r$  r(  r-  rA  rD  rM  rU  rX  r]  rc  encoderm  rn  ro  rs  rz  r~  r  r  r  r  rb   rC   r@   <module>r     sw         				 				 				   



    # # # # # # < < < < < < < <       $ $ $ $ $ $ A @ @ @ @ @ @ @                : 9 9 9 9 9                  ) ( ( ( ( (            , + + + + +"$ c** ))BHWll48889JKLL  
 <7" " "H	/ 	/ 	/  ?3 ?3 ?3D6 6 6 6r& & &" " "J 	 	 	  6  <  @  F   2  0 0 0  2% % %2  2  "  $ $ $P M 
  05 5 5,5 5 55 5 5    0 1 1 1*9 9 9x	 	 	 	  4   6# # # #  " " "L 	g		  @C C C:   M M M&
 
 
A A A"S S S S SrC   