
    j              	         % S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKrSSKrSSKrSSKJr  SSKJrJr  SSKJrJrJrJrJrJr  SSKJrJr  SS	KJr  SS
KJr  SSK J!r!J"r"J#r#J$r$  SSK%J&r'  SSK(J)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0J1r1J2r2J3r3J4r4J5r5  SSK(J6r7  SSK8J9r9  SSK:J;r;J<r<J=r=J>r>  SSK?J@r@  \(       a  SSKAJBrB  SSKJCrC  SSKJ%rD  SSKEJFrFJGrGJHrH  SrIS\JS'   \R                  " 5       rLS\JS'   SSS.rMS\JS'   \" S5      rN\" S 5      rOS!R                  \R                  " S"\" S#S$9S%   5      5      rRS\JS&'   \
R                  S':X  a
  S\S( jrTS\S) jr/    S]S* jrUS^S+ jrV S_     S`S, jjrWSaS- jrXSbS. jrY\R                  ScS/ j5       r[    SdS0 jr\\SeS1 j5       r]\    SfS2 j5       r]    SgS3 jr]ShS4 jr^SiS5 jr_S_SjS6 jjr`SkS7 jraSlS8 jrbSmS9 jrcSnS: jrdSoS; jre      SpS< jrf\      SqS= j5       rg\      SrS> j5       rg      SsS? jrgStS@ jrh\i" SA5      rjS\JSB'   SuSC jrkSuSD jrlSvSE jrmSwSF jrnSxSG jroSySH jrp\R                  SzSI j5       rqS{SJ jrrS|S}SK jjrsS~SL jrt S       SSM jjruSSSN jjrvSSO jrwSSP jrxSQR                  SR5      rz\zSS-  r{\zST-  r|SSU jr}SSV jr~SSW jrSSX jr        SSY jrSSZ jrSS[ jrg)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_PATHP   i  )httphttpsDEFAULT_PORTS_KT_VTz, z,\s*T)accept_encodingzaccept-encodingDEFAULT_ACCEPT_ENCODINGwin32c                D    SS K n UR                  UR                  S5      n[	        UR                  US5      S   5      nUR                  US5      S   nU(       a  U(       d  gUR                  S5      n[        S U5      nU Hs  nUS:X  a  SU ;  a    g	UR                  SS
5      nUR                  SS5      nUR                  SS5      n[        R                  " XP[        R                  5      (       d  Ms    g	   g! [         a     gf = f! [        [        4 a     gf = f)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)hostrF   internetSettingsproxyEnableproxyOverridetests         Q/var/www/html/Sattelite-Image/venv/lib/python3.13/site-packages/requests/utils.pyproxy_bypass_registryrZ   c   s!   	
	%~~((N 
 f112BMRSTUVK"//0@/RSTUM -
 &++C0t]3!Dy d?<<U+D<<U+D<<T*DxxBDD)) " C  		 $ 		s#   C< AD <
D	D	DDc                L    [        5       (       a  [        U 5      $ [        U 5      $ )zReturn True, if the host should be bypassed.

Checks proxy settings gathered from the environment, if specified,
or the registry.
)r   r   rZ   )rT   s    rY   r   r      s#     "##+D11(..    c                P    [        U [        5      (       a  U R                  5       $ U $ )z/Returns an internal sequence dictionary update.)
isinstance_SupportsItemsitems)ds    rY   dict_to_sequencerb      s"    
 !^$$wwyHr\   c                V   S nSn[         (       d&  [        U [        5      (       a  U R                  S5      n [	        U S5      (       a  [        U 5      nO[	        U S5      (       a  U R
                  nOm[	        U S5      (       a\   U R                  5       n[        R                  " U5      R                  nSU R                  ;  a  [        R                  " S[        5        [	        U S5      (       ab   U R#                  5       n[	        U S	5      (       a@  Uc=   U R%                  SS
5        U R#                  5       nU R%                  U=(       d    S5        Uc  Sn[)        SX-
  5      $ ! [        R                  [         4 a     Nf = f! [&         a    Sn NAf = f! [&         a    Ub  Un NVf = f)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   osfstatst_sizemodewarningswarnr(   ioUnsupportedOperationAttributeErrorri   rj   rL   max)ototal_lengthcurrent_positionrg   s       rY   	super_lenr{      s   L<Jq#.. HHWq)1v	E		uu	H			XXZF 88F+33L !&& 2 $
 q&	% vvx q&!!l&:	%FF1aL#$668L FF+0q1 q,122e ''8 	 		X  %#$L%%  	0
 '#/ 	0s6   E$ 0F <F $F FFFF('F(c                   [        U [        5      (       a  U R                  S5      n [        R                  R                  S5      nUb  U4nOS [         5       n SSKJnJn  SnU HJ  n[        R                  R                  U5      n[        R                  R                  U5      (       d  MH  Un  O   Uc  g[        U 5      n	U	R                  n
U
c  g U" U5      R                  U
5      nU(       a:  [        U5      (       a)  US   (       a  SOSnX   =(       d    SUS	   =(       d    S4$ gg! U[         4 a    U(       a  e  gf = f! ["        [$        4 a     gf = f)
z;Returns the Requests tuple auth for a given url from netrc.rd   NETRCNc              3  ,   #    U  H
  nS U 3v   M     g7f)z~/N ).0fs     rY   	<genexpr>!get_netrc_auth.<locals>.<genexpr>   s     9[Rs8[s   r   )NetrcParseErrornetrcr    rk   )r^   r   decodern   environgetr4   r   r   path
expanduserexistsr#   hostnameauthenticatorsanyrL   rG   rv   )urlraise_errors
netrc_filenetrc_locationsr   r   
netrc_pathr   locrirT   r3   login_is                rY   get_netrc_authr      sA   
 #ujj!(J%-9[9#0
 A''$$Q'Cww~~c"" 
	 ! c]{{<
	:&55d;F#f++%ay!a-2vayB?? &v  ) 	  	 ( s>   AE /	E 9E AD. .EE EE EEc                    [        U SS5      nU(       aO  [        U[        [        45      (       a3  US   S:w  a)  US   S:w  a  [        R
                  R                  U5      $ gggg)z0Tries to guess the filename of the given object.nameNr   <>)getattrr^   r!   r   rn   r   basename)objr   s     rY   guess_filenamer     s[    3%D
4#u..47c>d2hRUoww%% GV>.tr\   c                   [         R                  R                  U 5      (       a  U $ [         R                  R                  U 5      u  pU(       a  [         R                  R                  U5      (       dh  [         R                  R                  U5      u  pU(       d  O?SR	                  X2/5      nU(       a&  [         R                  R                  U5      (       d  Mh  [
        R                  " U5      (       d  U $ [
        R                  " U5      nX$R                  5       ;  a  U $ [         R                  R                  UR                  S5      S   5      S   n[        R                  " US9u  pg [         R                  " XdR                  U5      5        [         R                  " U5        U$ ! [         R                  " U5        f = f)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   )suffix)rn   r   r   rN   joinzipfile
is_zipfileZipFilenamelistsplitexttempfilemkstempwritereadclose)r   archivememberprefixzip_filer   fdextracted_paths           rY   extract_zipped_pathsr   "  s;   
 
ww~~d ggmmD)OG
"''..11''--0 6*+ "''..11 g&&w'H&&(( WWfll3/34R8F!))8B
]]6*+
 	s   .%F+ +Gc              #  T  #    [         R                  " [        R                  R	                  U 5      S9u  p [        R
                  " US5       nUv   SSS5        [        R                  " X 5        g! , (       d  f       N%= f! [         a    [        R                  " U5        e f = f7f)z-Write a file to the disk in an atomic fashion)dirwbN)	r   r   rn   r   dirnamefdopenrP   BaseExceptionremove)filenametmp_descriptortmp_nametmp_handlers       rY   atomic_openr   H  sz       (//BGGOOH4MNNYY~t, -


8& -,  
		(s4   4B(B A2B 1B(2
B <B "B%%B(c                    U c  g[        U [        [        [        [        45      (       a  [        S5      e[        U 5      $ )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   boolrJ   rM   r   values    rY   from_key_val_listr   U  s9    ( }%#udC011FGGur\   c                    g Nr   r   s    rY   to_key_val_listr   r  s    *-r\   c                    g r   r   r   s    rY   r   r   t  s      r\   c                    U c  g[        U [        [        [        [        45      (       a  [        S5      e[        U [        5      (       a  [        U R                  5       5      $ [        U 5      $ )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   rJ   rM   r_   listr`   r   s    rY   r   r   x  sV    & }%#udC011FGG%((EKKM"";r\   c                    / n[        U 5       H8  nUSS USS s=:X  a  S:X  a  O  O[        USS 5      nUR                  U5        M:     U$ )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      rY   parse_list_headerr     sT    . F"5)8tBCy'C''Qr
3Dd * Mr\   c                    0 n[        U 5       HK  nSU;  a  SX'   M  UR                  SS5      u  p0U SS U SS s=:X  a  S:X  a  O  O[        U SS 5      n XU'   MM     U$ )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   rN   r   )r   r   r   r   s       rY   parse_dict_headerr     sr    , %'F"5)d?FLjja(!9bc
)c)(q5Et * Mr\   c                    U (       aN  U S   U S   s=:X  a  S:X  a;  O  U $ U SS n U(       a	  U SS S:w  a"  U R                  SS5      R                  S	S5      $ U $ )
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   Nrk   z\\\z\")rP   )r   is_filenames     rY   r   r     sd     qU2Y-#- L a eBQi61==.66ucBBLr\   c                \    U  Vs0 s H  oR                   UR                  _M     nnU$ s  snf )ztReturns a key/value dictionary from a CookieJar.

:param cj: CookieJar object to extract cookies from.
:rtype: dict
)r   r   )cjcookiecookie_dicts      rY   dict_from_cookiejarr     s.     <>>2;;,2K> ?s    )c                    [        X5      $ )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     rY   add_dict_to_cookiejarr     s     {//r\   c                Z   [         R                  " S[        5        [        R                  " S[        R
                  S9n[        R                  " S[        R
                  S9n[        R                  " S5      nUR                  U 5      UR                  U 5      -   UR                  U 5      -   $ )zdReturns 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=["\']*(.+?)["\'>])rr   rs   DeprecationWarningrQ   compilerS   findall)content
charset_re	pragma_rexml_res       rY   get_encodings_from_contentr   
  s    
 MM1 	 @MJ

IQSQUQUVIZZ?@F 	7#


G
$	%
..
!	"r\   c                N   U R                  S5      nUS   R                  5       USS p20 nSnU Hq  nUR                  5       nU(       d  M  UR                  S5      =nS:w  d  M5  USU R                  U5      nXgS-   S R                  U5      n	XUR                  5       '   Ms     X$4$ )zReturns content type and parameters from given header.

:param header: string
:return: tuple containing content type and dictionary of
     parameters.
rB   r   r   Nz"' r   r   )rN   stripfindlower)
headertokenscontent_typeparamsparams_dictstrip_charsparamidxkeyr   s
             rY   _parse_content_type_headerr   #  s     \\#F!!9??,fQRj&)+KK5UZZ_,c3+##K0C')$**;7E',		$  $$r\   c                    U R                  S5      nU(       d  g[        U5      u  pSU;   a  US   R                  S5      $ SU;   a  gSU;   a  gg)	zqReturns 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   )headersr   r   s      rY   get_encoding_from_headersr   9  s^     ;;~.L5lCLFi &&u--\) *r\   c              #    #    UR                   c  U  Sh  vN   g[        R                  " UR                   5      " SS9nU  H!  nUR                  U5      nU(       d  M  Uv   M#     UR                  SSS9nU(       a  Uv   gg Nm7f)zStream decodes an iterator.NrP   errorsr\   T)final)encodingcodecsgetincrementaldecoderr   )iteratorrdecoderchunkrvs        rY   stream_decode_response_unicoder  R  s~     
 	zz**1::6iHG^^E"2H  
4	(B	 
 	s   BBAB&Bc                    g r   r   stringslice_lengths     rY   iter_slicesr  e  s     $'r\   c                    g r   r   r  s     rY   r  r  i  s     "%r\   c              #     #    SnUb  US::  a  [        U 5      nU[        U 5      :  a  XX!-    v   X!-  nU[        U 5      :  a  M  gg7f)z Iterate over slices of a string.r   N)rf   )r  r  poss      rY   r  r  m  sR      C|q06{
F
3-.. F
s   AAAc                v   [         R                  " S[        5        U R                  c  g/ n[	        U R
                  5      nU(       a   [        U R                  U5      $  [        U R                  U=(       d    SSS9$ ! [         a    UR                  U5         N<f = f! [         a    U R                  s $ f = f)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.)Nrd   rP   r  )
rr   rs   r   r   r   r   r!   UnicodeErrorr   	TypeError)r	  tried_encodingsr  s      rY   get_unicode_from_responser  y  s     MM1 	 	yy!#O )3H	-qyy(++
199h1')DD  	-""8,	-  yys$   	A>  B >BBB87B8zBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~UNRESERVED_SETc                   U R                  S5      n[        S[        U5      5       Hp  nX   SS n[        U5      S:X  aN  UR                  5       (       a9   [	        [        US5      5      nU[        ;   a  XAU   SS -   X'   M\  SX    3X'   Mg  SX    3X'   Mr     S	R                  U5      $ ! [         a    [        SU S35      ef = f)
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   rk      z"Invalid percent-escape sequence: ''Nr   )
rN   rangerf   isalnumchrrJ   rM   r*   r  r   )uripartsihcs        rY   unquote_unreservedr(    s     IIcNE1c%j!HQqMq6Q;199;;LAr
O N"Qx|+uxj>58*~EH " 775>  L #EaS!JKKLs   B,,Cc                d    SnSn [        [        U 5      US9$ ! [         a    [        XS9s $ f = f)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      rY   requote_urir-    sG     /0	5 ',3DEE 5 S44	5s    //c           
     x   [         R                  " S[        R                  " U 5      5      S   nUR	                  S5      u  p4[         R                  " S[        R                  " [        [        U5      5      5      5      S   n[         R                  " S[        R                  " U5      5      S   U-  nX%-  Xe-  :H  $ )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_atonrN   dotted_netmaskrJ   )ipnetipaddrnetaddrbitsnetmasknetworks          rY   address_in_networkr;    s     ]]4!1!1"!56q9FIIcNMGmmD&"2"2>#d)3L"MNqQGmmD&"2"27";<Q?'IG'"344r\   c                t    SSSU -
  -  S-
  -  n[         R                  " [        R                  " SU5      5      $ )zuConverts 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)r1  	inet_ntoar/  pack)maskr8  s     rY   r3  r3    s7     b4i1,,DFKKd344r\   c                R     [         R                  " U 5        g! [         a     gf = f)z
:rtype: bool
FT)r1  r2  rL   )	string_ips    rY   is_ipv4_addressrC    s.    #   s    
&&c                   U R                  S5      S:X  aU   [        U R                  S5      S   5      nUS:  d  US:  a  g [        R
                  " U R                  S5      S   5        gg! [         a     gf = f! [         a     gf = f)zJ
Very simple check of the cidr format in no_proxy variable.

:rtype: bool
r   r   Fr=  r   T)countrJ   rN   rM   r1  r2  rL   )string_networkr@  s     rY   is_valid_cidrrG    s     C A%	~++C034D !8tby	^11#6q9:
    		  		s#   A, (A< ,
A98A9<
B	B	c              #  ^  #    USLnSnU(       a2  [         R                  R                  U 5      nU[         R                  U '    Sv   U(       a)  Uc  [         R                  U 	 gU[         R                  U '   gg! U(       a)  Uc  [         R                  U 	 f U[         R                  U '   f f = f7f)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)rn   r   r   )env_namer   value_changed	old_values       rY   set_environrL    s      %M IJJNN8,	$

81 JJx('0

8$	 = JJx('0

8$	 s   A B-A8 1B-82B**B-c                   SS jnUnUc  U" S5      n[        U 5      nUR                  nUc  gU(       a  S UR                  SS5      R                  S5       5       n[	        U5      (       a5  U H.  n[        U5      (       a  [        XW5      (       a    gM'  XW:X  d  M.    g   O~UnUR                  (       a  US	UR                   3-  nU HS  n	U	R                  S
5      n	XY:X  d  X:X  a    gS
U	-   n	UR                  U	5      (       d  UR                  U	5      (       d  MS    g   [        SU5          [        U5      n
SSS5        W
(       a  gg! [        [        R                  4 a    Sn
 N/f = f! , (       d  f       N9= f)z@
Returns whether we should bypass proxies or not.

:rtype: bool
c                    [         R                  R                  U 5      =(       d-    [         R                  R                  U R                  5       5      $ r   )rn   r   r   upper)r   s    rY   	get_proxy(should_bypass_proxies.<locals>.get_proxy3  s-    zz~~c"AbjjnnSYY[&AAr\   Nno_proxyTc              3  6   #    U  H  o(       d  M  Uv   M     g 7fr   r   )r   rT   s     rY   r   (should_bypass_proxies.<locals>.<genexpr>E  s     X+O4SW$$+Os   
	 r   ,:rC   F)r   r!   return
str | None)r#   r   rP   rN   rC  rG  r;  portlstripendswithrL  r   r  r1  gaierror)r   rR  rP  no_proxy_argparsedr   no_proxy_hostsproxy_iphost_with_portrT   bypasss              rY   should_bypass_proxiesrd  *  si   B
 LZ(c]FH Y8+;+;C+D+J+J3+OX8$$* **)(==# >)   + &N{{Afkk]"33&{{3'#~'=Tz$$T**n.E.Ed.K.K ' 
Z	.	!(+F 
/  6??+ 	F	 
/	.s*   ,E,.E

E)&E,(E))E,,
E:c                6    [        XS9(       a  0 $ [        5       $ )z5
Return a dict of environment proxies.

:rtype: dict
rR  )rd  r   )r   rR  s     rY   get_environ_proxiesrg  i  s     S4	|r\   c                >   U=(       d    0 n[        U 5      nUR                  c+  UR                  UR                  UR                  S5      5      $ UR                  S-   UR                  -   UR                  SUR                  -   S/nSnU H  nXQ;   d  M
  X   n  U$    U$ )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#   r   r   scheme)r   proxiesurlparts
proxy_keysproxy	proxy_keys         rY   select_proxyrp  u  s     mG}H {{8??GKK,>?? 	%("3"338$$$	J E	&EL  
 Lr\   c                `   Ub  UO0 n[        [        U R                  5      n[        U5      R                  nUR                  S5      nUR                  5       nU(       aO  [        X5S9(       dA  [        X5S9nUR                  XGR                  S5      5      nU(       a  UR                  XH5        U$ )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
rR  rf  ri  )
r   r!   r   r#   rj  r   copyrd  rg  
setdefault)	requestrk  	trust_envr   rj  rR  new_proxiesenviron_proxiesrn  s	            rY   resolve_proxiesrx    s     !,g"G
sGKK
 Cc]!!F{{:&H,,.K.sF-cE##F,?,?,FG""61r\   c                    U  S[          3$ )zC
Return a string representing the default user agent.

:rtype: str
r   r   )r   s    rY   default_user_agentrz    s     V1[M""r\   c                 :    [        [        5       [        SSS.5      $ )z1
:rtype: requests.structures.CaseInsensitiveDict
z*/*z
keep-alive)z
User-AgentzAccept-EncodingAccept
Connection)r,   rz  r=   r   r\   rY   default_headersr~    s%     ,.6&		
 r\   c                   / nSnU R                  U5      n U (       d  U$ [        R                  " SU 5       H  n UR                  SS5      u  pESUR                  S5      0nUR                  S5       H9  n UR                  S5      u  pU R                  U5      XhR                  U5      '   M;     UR	                  U5        M     U$ ! [         a    USpT Nf = f! [         a       M8  f = f)	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, *<rB   r   r   r   z<> '"r   )r   rQ   rN   rM   r   )	r   linksreplace_charsvalr   r   linkr   r   s	            rY   parse_header_linksr    s     #%EMKK&Exx&	"))C+KC !&syy':;\\#&E"[[-
 .3[[-GD=)* ' 	T! '$ L  	"r	"  s#   C6CCC
C('C( asciirk      c                   U SS nU[         R                  [         R                  4;   a  gUSS [         R                  :X  a  gUSS [         R                  [         R
                  4;   a  gUR                  [        5      nUS:X  a  g	US:X  a"  USSS2   [        :X  a  g
USSS2   [        :X  a  gUS:X  a  USS [        :X  a  gUSS [        :X  a  gg)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_BErE  _null_null2_null3)datasample	nullcounts      rY   guess_json_utfr    s     "1XF&%%v':':;;bqzV__$bqzf))6+>+>??U#IA~A~#A#;& !$Q$<6!A~"1:!":r\   c                    [        U 5      nUu  p4pVpxn	UR                  n
U
(       d  XzpzU(       a"  [        [        U
5      n
SR	                  XJ/5      n
Uc  UnUc  Sn[        X:USX45      $ )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
@r   )r   netlocr   r!   r   r$   )r   
new_schemer_  rj  auth_host_portr   queryfragmentr  s              rY   prepend_scheme_if_neededr    sw     s^F8>5F%X ]]F c6"4.)~|vtRABBr\   c                    [        U 5      n [        UR                  5      [        UR                  5      4nU$ ! [        [
        4 a    Sn U$ f = f)zoGiven a url with authentication components, extract them into a tuple of
username,password.

:rtype: (str,str)
)r   r   )r#   r"   usernamepasswordrv   r  )r   r_  r  s      rY   get_auth_from_urlr  .  sU     c]F('&//*BC K I& Ks   *9 AAc                <    U u  p[        XS5        [        XS5        g)zVerifies 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   s      rY   check_header_validityr  ?  s     KD&*&+r\   c           
         [        U[        5      (       a
  [        U   nO=[        U[        5      (       a
  [        U   nO[        SU< SU  S[        U5       35      eUR                  U5      (       d  US:X  a  SOSn[        SU SU< 35      eg )	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)   typerR   )r   header_partheader_validator_index	validatorheader_kinds        rY   r  r  J  s    
 +s##*+AB		K	'	'+,BC	K?'& :115k1B0CE
 	

 ??;'' 6! ;f&&1]"[OE
 	
 (r\   c                z    [        U 5      u  pp4pVU(       d  X2p2UR                  SS5      S   n[        XX4US45      $ )zK
Given a url remove the fragment and the authentication part.

:rtype: str
r  r   r   r   )r#   rsplitr$   )r   rj  r  r   r   r  	_fragments          rY   urldefragauthr  b  sG     6>c]2FD% ]]3"2&FvtUB?@@r\   c                    [        U R                  SS5      nUb3  [        U R                  [        5      (       a   U" U R                  5        g[        S5      e! [
         a    [        S5      ef = f)z^Move 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   rL   r+   )prepared_request	body_seeks     rY   rewind_bodyr  s  sz     (--vt<I''" "	&556 $$QRR  	'M 	s   A A/)rT   r!   rX  r   )ra   z6_t.SupportsItems[Any, Any] | Iterable[tuple[Any, Any]]rX  zIterable[tuple[Any, Any]])rx   r   rX  rJ   )F)r   z
_t.UriTyper   r   rX  ztuple[str, str] | None)r   r   rX  rY  )r   r!   rX  r!   )r   r!   rX  z%Generator[BufferedWriter, None, None])r   z4Mapping[Any, Any] | Iterable[tuple[Any, Any]] | NonerX  zdict[Any, Any] | None)r   NonerX  r  )r   z6_t.SupportsItems[_KT, _VT] | Iterable[tuple[_KT, _VT]]rX  zlist[tuple[_KT, _VT]])r   z=_t.SupportsItems[_KT, _VT] | Iterable[tuple[_KT, _VT]] | NonerX  zlist[tuple[_KT, _VT]] | None)r   r!   rX  	list[str])r   r!   rX  dict[str, str | None])r   r!   r   r   rX  r!   )r   r-   rX  r  )r   r-   r   dict[str, str]rX  r-   )r   r!   rX  r  )r   r!   rX  ztuple[str, dict[str, Any]])r   CaseInsensitiveDict[str]rX  rY  )r  zIterable[bytes]r	  r2   rX  z"Generator[str | bytes, None, None])r  r   r  
int | NonerX  zGenerator[bytes, None, None])r  r!   r  r  rX  zGenerator[str, None, None])r  zbytes | strr  r  rX  z"Generator[bytes | str, None, None])r	  r2   rX  zstr | bytes | None)r#  r!   rX  r!   )r4  r!   r5  r!   rX  r   )r@  rJ   rX  r!   )rB  r!   rX  r   )rF  r!   rX  r   )rI  r!   r   rY  rX  zGenerator[None, None, None])r   r!   rR  rY  rX  r   r   )r   r!   rR  rY  rX  r  )r   r!   rk  dict[str, str] | NonerX  rY  )T)rt  zRequest | PreparedRequestrk  r  ru  r   rX  r  )zpython-requests)r   r!   rX  r!   )rX  r  )r   r!   rX  zlist[dict[str, str]])r  r   rX  rY  )r   r!   r  r!   rX  r!   )r   r!   rX  ztuple[str, str])r   tuple[str | bytes, str | bytes]rX  r  )r   r  r  zstr | bytesr  rJ   rX  r  )r   r!   rX  r!   )r  r0   rX  r  )__doc__
__future__r   r  
contextlibrt   rn   rQ   r1  r/  sysr   rr   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modelsr0   r1   r2   r4   __annotations__wherer5   r9   r:   r;   r   rN   r=   platformrZ   rb   r{   r   r   r   contextmanagerr   r   r   r   r   r   r   r   r   r   r   r  r  r  	frozensetr  r(  r-  r;  r3  rC  rG  rL  rd  rg  rp  rx  rz  r~  r  rl   r  r  r  r  r  r  r  r  r  r  r   r\   rY   <module>r     s   #   	 	 	   
    # /  1  $  4    : (  ,(!::)U ) $kkm  + !#S1u 1enen "&HHWl489JKL"  
 <<7$L	/=D3P +01	1#'11h&#L 	 	?: 
 - 
 -	 A   
 H!@@F202%,2"*'& 
''!+'!' 
' 
%%)%% 
%		'1	'	&T "M 
05,550 1 1,<~	: &"  	>#"L 	g		@C<",
+

  
 
	
0A"Sr\   