+
     h_  c            	       s   R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIHt ^ RIHtHt ^RIHt ^RIHt ^RIHtHtHtHt ^RIHtHtHtHtHtHt ^RIH t! ^R	IH"t"H#t#H$t$H%t%H&t&H't'H(t( ^R
I)H*t* ^RI+H,t,H-t-H.t.H/t/ ^RI0H1t1 RBt2]Pf                  ! 4       t4R^PRR/t5RPm                  ]Pn                  ! R]! RR7      R,          4      4      t8]Pr                  R8X  d   R t:R t"R t;R t<RCR lt=R t>R t?]P                  R 4       tAR tBR tCR  tDR! tERCR" ltFR# tGR$ tHR% tIR& tJR' tKR( tLR) tMR* tN]O! RD4      tPR+ tQR, tRR- tSR. tTR/ tUR0 tV]P                  R1 4       tWR2 tXRER3 ltYR4 tZRFR5 lt[RGR6 lt\R7 t]R8 t^R9P                  R:4      t`]`^,          ta]`^,          tbR; tcR< tdR= teR> tfR? tgR@ thRA tiR# )Hz
requests.utils
~~~~~~~~~~~~~~

This module provides utility functions that are used within Requests
that are also useful for external consumption.
N)OrderedDict)make_headers	parse_url)certs__version__)_HEADER_VALIDATORS_BYTE_HEADER_VALIDATORS_STRHEADER_VALIDATORSto_native_string)Mapping
basestringbytes
getproxiesgetproxies_environmentinteger_types)parse_http_list)proxy_bypassproxy_bypass_environmentquotestrunquoteurlparse
urlunparsecookiejar_from_dict)FileModeWarningInvalidHeader
InvalidURLUnrewindableBodyError)CaseInsensitiveDictZhttpZhttpsi  z, z,\s*T)Zaccept_encodingzaccept-encodingZwin32c                 sn    ^ RI p TP                  TP                  R4      p\	        TP                  TR4      ^ ,          4      pTP                  TR4      ^ ,          pT'       d	   T'       g   R# TP                  R4      p\        RT4      pT Fx  pTR8X  d   RT 9  d    R	# TP                  RR
4      pTP                  RR4      pTP                  RR4      p\        P                  ! YP\        P                  4      '       g   Kw   R	# 	  R#   \         d     R# i ; i  \        \        3 d     R# i ; i)    NFz;Software\Microsoft\Windows\CurrentVersion\Internet SettingsZProxyEnableZProxyOverride;z<local>Z.Tz\.Z*z.*Z?)winregImportErrorZOpenKeyZHKEY_CURRENT_USERintZQueryValueExOSError
ValueErrorsplitZfilterreplacerematchI)hostr!   ZinternetSettingsZproxyEnableZproxyOverrideZtests   &     ?/usr/lib/python3.14/site-packages/pip/_vendor/requests/utils.pyproxy_bypass_registryr-   L   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#   D AD DDD43D4c                sN    \        4       '       d   \        V 4      # \        V 4      # )zReturn True, if the host should be bypassed.

Checks proxy settings gathered from the environment, if specified,
or the registry.
)r   r   r-   )r+      &r,   r   r   r   s#     "##+D11(..    c                sJ    \        V R4      '       d   V P                  4       p V # )z/Returns an internal sequence dictionary update.items)hasattrr0   )Zdr.   r,   dict_to_sequencer2   ~   s!     q'GGIHr/   c                 sd   R p^ p\        V \        4      '       d   V P                  R4      p \        V R4      '       d   \	        V 4      pM\        V R4      '       d   V P                  pMo\        V R4      '       d^    V P                  4       p\        P                  ! V4      P                  pRV P                  9  d   \        P                  ! R\        4       \        V R4      '       df    V P!                  4       p\        V R4      '       dC   Vf?    V P#                  ^ ^4       V P!                  4       pT P#                  T;'       g    ^ 4       Vf   ^ p\'        ^ W,
          4      #   \        P                  \        3 d     Li ; i  \$         d    ^ p LHi ; i  \$         d
    Te   Tp L_i ; i)	Nutf-8Z__len__lenfilenoZ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)
isinstancer   encoder1   r4   r5   osZfstatZst_sizeZmodewarningswarnr   ioZUnsupportedOperationAttributeErrorr6   r7   r$   Zmax)ZoZtotal_lengthZcurrent_positionr5      &   r,   	super_lenr@      s   L!SHHWq)1v	E		uu	H			XXZF 88F+33L !&& 2 $
 q&	% vvx q&!!l&:	%FF1aL#$668L FF+00q1 q,122e ''8 	 		X  %#$L%%  	0
 '#/ 	0s<   <E' +F 5F F 'FFFFF/.F/c                s   \         P                  P                  R4      pVe   V3pMR \         4       p ^ RIHpHp RpV FL  p \         P                  P                  V4      p\         P                  P                  T4      '       g   KJ  Tp M	  Vf   R# \        V 4      p	Rp
\        V \        4      '       d   V
P                  R4      p
V	P                  P                  V
4      ^ ,          p V! V4      P!                  V4      pV'       d%   V^ ,          '       d   ^ M^pW,          V^,          3# R#   \         d      R# i ; i  T\"        3 d    T'       d   h  R# i ; i  \$        \&        3 d     R# i ; i)z;Returns the Requests tuple auth for a given url from netrc.ZNETRCNc              3   s,   "   T F
  pR V 2x  K  	  R# 5i)z~/N ).0f   & r,   	<genexpr>Z!get_netrc_auth.<locals>.<genexpr>   s     9[Rs8[s   )NetrcParseErrornetrcs   :ascii)r:   environgetNETRC_FILESrG   rF   pathZ
expanduserZKeyErrorexistsr   r8   r   decodenetlocr&   Zauthenticatorsr$   r"   r>   )urlZraise_errorsZ
netrc_fileZnetrc_locationsrF   rG   Z
netrc_pathrC   ZlocZriZsplitstrr+   _netrcZlogin_is   &&            r,   get_netrc_authrR      sY    (J%-9[9-0
 Agg((+ ww~~c"" 
 ! c] c3w/Hyyx(+
	:&55d;F%ayy!a33 3   	:  ) 	  	 ( sr   E$ D4%"E$ 
E$ AE$ /E E E 4E?E$ EE$ E!E!E$  E!!E$ $E98E9c                s    \        V RR4      pV'       dX   \        V\        4      '       d@   V^ ,          R8w  d0   VR,          R8w  d    \        P                  P                  V4      # R# R# R# R# )z0Tries to guess the filename of the given object.nameNZ<Z>)getattrr8   r   r:   rL   Zbasename)ZobjrS   rD   r,   guess_filenamerV     sW    3%D
4,,aCDHPSOww%% ET,tr/   c                s   \         P                  P                  V 4      '       d   V # \         P                  P                  V 4      w  rV'       dd   \         P                  P                  V4      '       g?   \         P                  P                  V4      w  rV'       g   MRP	                  W2.4      pKk  \
        P                  ! V4      '       g   V # \
        P                  ! V4      pW$P                  4       9  d   V # \        P                  ! 4       p\         P                  P	                  WRP                  R4      R,          4      p\         P                  P                  V4      '       g?   \        V4      ;_uu_ 4       pVP                  VP                  V4      4       RRR4       V# V#   + '       g   i     T# ; i)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.
/NrT   )r:   rL   rM   r&   joinzipfileZ
is_zipfileZZipFileZnamelisttempfileZ
gettempdiratomic_openZwriteZread)rL   ZarchiveZmemberZprefixZzip_fileZtmpZextracted_pathZfile_handlers   &       r,   extract_zipped_pathsr\     s2   
 
ww~~d ggmmD)OG
"''..11''--0 6*+g&&w'H&&(( 


CWW\\#||C'8'<=N77>>.))((Lx}}V45 )> )(s    !F--F>	c              #  sr  "   \         P                  ! \        P                  P	                  V 4      R7      w  r \        P
                  ! VR4      ;_uu_ 4       pVx  RRR4       \        P                  ! W 4       R#   + '       g   i     L(; i  \         d    \        P                  ! T4       h i ; i5i)z-Write a file to the disk in an atomic fashion)ZdirZwbN)	rZ   Zmkstempr:   rL   ZdirnameZfdopenr'   ZBaseExceptionZremove)ZfilenameZtmp_descriptorZtmp_nameZtmp_handlerr?   r,   r[   r[   1  s}       (//BGGOOH4MNNYY~t,, -


8& -,  
		(s4   7B7B A>B <B7>B		B #B44B7c                s    V f   R# \        V \        \        \        \        34      '       d   \        R4      h\        V 4      # )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)r8   r   r   boolr#   r%   r    valuer.   r,   from_key_val_listra   >  s9    $ }%#udC011FGGur/   c                s    V f   R# \        V \        \        \        \        34      '       d   \        R4      h\        V \        4      '       d   V P                  4       p \        V 4      # )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]   )	r8   r   r   r^   r#   r%   r
   r0   Zlistr_   r.   r,   to_key_val_listrb   Y  sP    " }%#udC011FGG%!!;r/   c                s    . p\        V 4       F>  pVR,          VRR u;8X  d   R8X  d   M M\        V^R 4      pVP                  V4       K@  	  V# )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
N   NN"rT   )_parse_list_headerunquote_header_valueappend)r`   resultitem   &  r,   parse_list_headerrl   w  sR    . F"5)8tBCy'C''Qr
3Dd * Mr/   c                s    / p\        V 4       FR  pRV9  d   RW&   K  VP                  R^4      w  r0V R,          V RR u;8X  d   R8X  d   M M\        V ^R 4      p WV&   KT  	  V# )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
=Nrc   re   rT   )rf   r&   rg   )r`   ri   rj   rS   r?   r,   parse_dict_headerrn     sp    , F"5)d?FLjja(9bc
)c)(q5Et * Mr/   c                s    V '       d_   V ^ ,          V R,          u;8X  d   R8X  dB   M V # V ^R p V'       d   V R,          R8w  d#   V P                  RR4      P                  RR4      # V # )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
re   N   Nz\\Z\z\"rT   )r'   )r`   Zis_filename   &&r,   rg   rg     sb     qU2Y-#- L a eBi61==.66ucBBLr/   c                sZ    V  Uu/ uF  qP                   VP                  bK  	  ppV# u upi )ztReturns a key/value dictionary from a CookieJar.

:param cj: CookieJar object to extract cookies from.
:rtype: dict
)rS   r`   )cjZcookiecookie_dictrk   r,   dict_from_cookiejarrt     s.     <>>2;;,2K> ?s   (c                s    \        W4      # )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   )rr   rs   rq   r,   add_dict_to_cookiejarru     s     {//r/   c                sv   \         P                  ! R\        4       \        P                  ! R\        P
                  R7      p\        P                  ! R\        P
                  R7      p\        P                  ! R4      pVP                  V 4      VP                  V 4      ,           VP                  V 4      ,           # )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=["\']*(.+?)["\'>])Zflagsz+<meta.*?content=["\']*;?charset=(.+?)["\'>]z$^<\?xml.*?encoding=["\']*(.+?)["\'>])r;   r<   DeprecationWarningr(   Zcompiler*   Zfindall)contentZ
charset_reZ	pragma_reZxml_rer?   r,   get_encodings_from_contentrx     s    
 MM1 	 @MJ

IQSQUQUVIZZ?@F 	7#


G
$	%
..
!	"r/   c                sl   V P                  R4      pV^ ,          P                  4       VR,          r2/ pRpV Fx  pVP                  4       pV'       g   K  TRrVP                  R4      p	V	R8w  d/   VRV	 P                  V4      pWi^,           R P                  V4      pWVP                  4       &   Kz  	  W$3# )zReturns content type and parameters from given header

:param header: string
:return: tuple containing content type and dictionary of
     parameters
r    rd   NNz"' Trm   NrT   )r&   stripZfindZlower)
headerZtokenscontent_typeparamsZparams_dictZitems_to_stripparamkeyr`   Zindex_of_equalss
   &         r,   _parse_content_type_headerr     s     \\#F!!9??,fRj&KN5#jjoO"$,_-33NC134::>J',		$  $$r/   c                s    V P                  R4      pV'       g   R# \        V4      w  rRV9   d   VR,          P                  R4      # RV9   d   R# RV9   d   R# R# )	zqReturns encodings from given HTTP Header Dict.

:param headers: dictionary to extract encoding from.
:rtype: str
zcontent-typeNZcharsetz'"Ztextz
ISO-8859-1zapplication/jsonr3   )rJ   r   rz   )headersr|   r}   rk   r,   get_encoding_from_headersr     s^     ;;~.L5lCLFi &&u--\) *r/   c              #  s&  "   VP                   f   T  Rj  xL
  R# \        P                  ! VP                   4      ! RR7      pV  F"  pVP                  V4      pV'       g   K  Vx  K$  	  VP                  RRR7      pV'       d   Vx  R# R#  Lx5i)zStream decodes an iterator.Nr'   Zerrorsr/   T)Zfinal)encodingcodecsZgetincrementaldecoderrN   )ZiteratorrZdecoderZchunkZrvs   &&   r,   stream_decode_response_unicoder   4  s~      	zz**1::6iHG^^E"2H  
4	(B	 
 	s   BBAB$"B	Bc              #  s   "   ^ pVe   V^ 8:  d   \        V 4      pV\        V 4      8  d   WW!,            x  W!,          pK&  R# 5i)z Iterate over slices of a string.N)r4   )ZstringZslice_lengthZposs   && r,   iter_slicesr   E  sG     
C|q06{
F
3-.. s   AAc                sT   \         P                  ! R\        4       . p\        V P                  4      pV'       d    \        V P                  V4      #  \        V P                  VRR7      #   \         d    TP                  T4        L7i ; i  \         d    T P                  u # i ; i)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.)r'   r   )
r;   r<   rv   r   r   r   rw   ZUnicodeErrorrh   	TypeError)r   Ztried_encodingsr   rk   r,   get_unicode_from_responser   O  s     MM1 	 O )3H	-qyy(++
199hy99  	-""8,	-  yys#   A+ B +B
	B
B'&B'c                s   V P                  R4      p\        ^\        V4      4       F  pW,          R,          p\        V4      ^8X  da   VP                  4       '       dK    \	        \        V^4      4      pT\        9   d   YAT,          R,          ,           Y&   Ks  RY,           2Y&   K  RW,           2W&   K  	  RP                  V4      #   \         d    \        RT R24      hi ; i)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
Z%:r   rp   Nz"Invalid percent-escape sequence: 'Z':rp   NN )
r&   Zranger4   ZisalnumZchrr#   r%   r   UNRESERVED_SETrX   )uriZpartsZiZhZcs   &    r,   unquote_unreservedr   |  s     IIcNE1c%j!HSMq6Q;199;;LAr
O N"Qx|+uxj>58*~EH " 775>  L #EaS!JKKLs    CC&c                sr    RpRp \        \        V 4      VR7      #   \         d    \        YR7      u # i ; i)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!#$&'()*+,/:;=?@[]~)Zsafe)r   r   r   )r   Zsafe_with_percentZsafe_without_percentrk   r,   requote_urir     sG     /0	5 ',3DEE 5 S44	5s    66c           
     s   \         P                  ! R\        P                  ! V 4      4      ^ ,          pVP	                  R4      w  r4\         P                  ! R\        P                  ! \        \        V4      4      4      4      ^ ,          p\         P                  ! R\        P                  ! V4      4      ^ ,          V,          pW%,          We,          8H  # )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=LrW   )structZunpacksocket	inet_atonr&   dotted_netmaskr#   )ZipZnetZipaddrZnetaddrbitsZnetmaskZnetworks   &&     r,   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                s    R^^ V ,
          ,          ^,
          ,          p\         P                  ! \        P                  ! RV4      4      # )zuConverts mask from /xx format to xxx.xxx.xxx.xxx

Example: if mask is 24 function returns 255.255.255.0

:rtype: str
l    z>I)r   Z	inet_ntoar   Zpack)maskr   rD   r,   r   r     s7     b4i1,,DFKKd344r/   c                sX     \         P                  ! V 4       R#   \         d     R# i ; i)z
:rtype: bool
FT)r   r   r$   )Z	string_ipr.   r,   is_ipv4_addressr     s.    #   s    ))c                s<   V P                  R4      ^8X  db    \        V P                  R4      ^,          4      pT^8  g   T^ 8  d   R#  \        P
                  ! T P                  R4      ^ ,          4       R# R#   \         d     R# i ; i  \         d     R# i ; i)zJ
Very simple check of the cidr format in no_proxy variable.

:rtype: bool
rW   FT)countr#   r&   r%   r   r   r$   )Zstring_networkr   rD   r,   is_valid_cidrr     s     C A%	~++C034D !8tby	^11#6q9:
    		  		s#   !A: 
,B :B	B	BBc              #  sj  "   VRJpV'       d3   \         P                  P                  V 4      pV\         P                  V &    Rx  V'       d-   Xf   \         P                  V  R# V\         P                  V &   R# R#   T'       d+   Xf   \         P                  T  i T\         P                  T &   i i ; i5i)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)r:   rI   rJ   )Zenv_namer`   Zvalue_changedZ	old_values   &&  r,   set_environr     s      %MJJNN8,	$

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

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

8$	 s   ?B3A< 6B3<4B00B3c                sl   R pTpVf	   V! R4      p\        V 4      pVP                  f   R# V'       Ed   R VP                  RR4      P                  R4       4       p\	        VP                  4      '       dQ   V FI  p\        V4      '       d"   \        VP                  V4      '       d    R# K5  VP                  V8X  g   KH   R# 	  MxVP                  pVP                  '       d   VR	VP                   2,          pV F>  pVP                  P                  V4      '       g   VP                  V4      '       g   K=   R# 	  \        RV4      ;_uu_ 4         \        VP                  4      pRRR4       X'       d   R# R
#   \        \        P                  3 d    R
p L3i ; i  + '       g   i     L?; i)z@
Returns whether we should bypass proxies or not.

:rtype: bool
c                 s    \         P                  P                  V 4      ;'       g.    \         P                  P                  V P                  4       4      # N)r:   rI   rJ   Zupper)r   r.   r,   	get_proxyZ(should_bypass_proxies.<locals>.get_proxy  s0    zz~~c"AAbjjnnSYY[&AAr/   Nno_proxyTc              3   s8   "   T F  q'       g   K  Vx  K  	  R # 5ir   rA   )rB   r+   rD   r,   rE   Z(should_bypass_proxies.<locals>.<genexpr>  s     R%ITTDD%Is   	
Z r   Z,Z:F)r   hostnamer'   r&   r   r   r   portZendswithr   r   r   r   Zgaierror)	rP   r   r   Zno_proxy_argparsedZproxy_ipZhost_with_portr+   Zbypasss	   &&       r,   should_bypass_proxiesr     se   B
 LZ(c]Fx SX%5%5c2%>%D%DS%IR6??++$ **)&//8DD# E__0   % $__N{{{Afkk]"33 ??++D11^5L5LT5R5R  	 ! 
Z	.	.	!&//2F 
/  6??+ 	F		 
/	.s*   F#F  F F#F  F##F3	c                s>    \        WR7      '       d   / # \        4       # )z5
Return a dict of environment proxies.

:rtype: dict
r   )r   r   )rP   r   rq   r,   get_environ_proxiesr   :  s     S44	|r/   c                sd   T;'       g    / p\        V 4      pVP                  f,   VP                  VP                  VP                  R4      4      # VP                  R,           VP                  ,           VP                  RVP                  ,           R.pRpV F  pWQ9   g   K  W,          p V# 	  V# )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   rJ   scheme)rP   proxiesZurlpartsZ
proxy_keysproxyZ	proxy_keys   &&    r,   select_proxyr   F  s     mmG}H {{8??GKK,>?? 	%("3"338$$$	J E	&EL  
 Lr/   c                sX   Ve   TM/ pV P                   p\        V4      P                  pVP                  R4      pVP	                  4       pV'       dX   \        W5R7      '       gF   \        W5R7      pVP                  WGP                  R4      4      pV'       d   VP                  WH4       V# )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
r   r   r   )rP   r   r   rJ   Zcopyr   r   Z
setdefault)	Zrequestr   Z	trust_envrP   r   r   Znew_proxiesZenviron_proxiesr   s	   &&&      r,   resolve_proxiesr   `  s     !,g"G
++Cc]!!F{{:&H,,.K.sFF-cE##F,?,?,FG""61r/   c                s    V  R\          2# )zC
Return a string representing the default user agent.

:rtype: str
rW   r   )rS   r.   r,   default_user_agentr   {  s     V1[M""r/   c            
     s@    \        R\        4       R\        RRRR/4      # )z1
:rtype: requests.structures.CaseInsensitiveDict
z
User-AgentzAccept-EncodingZAcceptz*/*Z
Connectionz
keep-alive)r   r   DEFAULT_ACCEPT_ENCODINGrA   r/   r,   default_headersr     s/     ,.6e,		
 r/   c                s   . pRpV P                  V4      p V '       g   V# \        P                  ! RV 4       F  p VP                  R^4      w  rERVP                  R4      /pVP                  R4       F9  p VP                  R4      w  rT P                  T4      YhP                  T4      &   K;  	  VP	                  V4       K  	  V#   \         d    TRrT Li ; i  \         d      K:  i ; i)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   rP   z<> '"rm   )rz   r(   r&   r%   rh   )	r`   ZlinksZreplace_charsZvalrP   r}   Zlinkr~   r   s	   &        r,   parse_header_linksr     s     EMKK&Exx&	"))C+KC syy*+\\#&E"[[-
 .3[[-GD=)* ' 	T! '$ L  	"r	"  s#   C7CCCC+*C+Z rH   c                s   V R,          pV\         P                  \         P                  39   d   R# VR,          \         P                  8X  d   R# VR,          \         P                  \         P
                  39   d   R# VP                  \        4      pV^ 8X  d   R# V^8X  d)   VR,          \        8X  d   R	# VR
,          \        8X  d   R# V^8X  d)   VR,          \        8X  d   R# VR,          \        8X  d   R# R# )z
:rtype: str
:Ni   Nzutf-32:Ni   Nz	utf-8-sigro   zutf-16r3   :NNrp   z	utf-16-be:rd   Nrp   z	utf-16-lez	utf-32-bery   z	utf-32-leN)
r   ZBOM_UTF32_LEZBOM_UTF32_BEZBOM_UTF8ZBOM_UTF16_LEZBOM_UTF16_BEr   _null_null2_null3)ZdataZsampleZ	nullcountrk   r,   guess_json_utfr     s     "XF&%%v':':;;bzV__$bzf))6+>+>??U#IA~A~#;& $<6!A~":":r/   c                s    \        V 4      pVw  r4rVrxp	VP                  p
V
'       g   YzrzV'       d   RP                  WJ.4      p
Vf   TpVf   Rp\        W:VRW34      # )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   rO   rX   r   )rP   Z
new_schemer   r   authr+   r   rL   queryfragmentrO   s   &&         r,   prepend_scheme_if_neededr     sk     s^F6<3F$d8 ]]F 4.)~|vtRABBr/   c                s    \        V 4      p \        VP                  4      \        VP                  4      3pV#   \        \
        3 d    Rp T# i ; i)zoGiven a url with authentication components, extract them into a tuple of
username,password.

:rtype: (str,str)
)r   r   )r   r   ZusernameZpasswordr>   r   )rP   r   r   rk   r,   get_auth_from_urlr     sU     c]F('&//*BC K I& Ks   *9 AAc                s>    V w  r\        W^ 4       \        W^4       R# )zVerifies that header parts don't contain leading whitespace
reserved characters, or return characters.

:param header: tuple, in the format (name, value).
N)_validate_header_part)r{   rS   r`   rk   r,   check_header_validityr   
  s     KD&*&+r/   c           
      s:   \        V\        4      '       d   \        V,          pMB\        V\        4      '       d   \        V,          pM\        R V: RV  R\        V4       24      hVP                  V4      '       g   V^ 8X  d   RMRp\        RV RV: 24      hR# )zHeader part (z) from z# must be of type str or bytes, not rS   r`   zTInvalid leading whitespace, reserved character(s), or return character(s) in header z: N)r8   r   r   r   r   r   Ztyper)   )r{   Zheader_partZheader_validator_indexZ	validatorZheader_kinds   &&&  r,   r   r     s    +s##*+AB		K	'	'+,BC	K?'& :115k1B0CE
 	

 ??;'' 6! ;f&&1]"[OE
 	
 (r/   c                s    \        V 4      w  rr4rVV'       g   Y2r2VP                  R^4      R,          p\        WW4VR34      # )zK
Given a url remove the fragment and the authentication part.

:rtype: str
r   r   rT   )r   Zrsplitr   )rP   r   rO   rL   r}   r   r   s   &      r,   urldefragauthr   (  sG     5=SM1FD% ]]3"2&FvtUB?@@r/   c                s    \        V P                  RR4      pVe6   \        V P                  \        4      '       d    V! V P                  4       R# \        R4      h  \
         d    \        R4      hi ; i)z^Move file pointer back to its recorded starting position
so it can be read again on redirect.
r7   Nz;An error occurred when rewinding request body for redirect.z+Unable to rewind request body for redirect.)rU   Zbodyr8   Z_body_positionr   r$   r   )Zprepared_requestZ	body_seekrD   r,   rewind_bodyr   9  sy     (--vt<I''" "	&556 $$QRR  	'M 	s   A A3)z.netrcrQ   )FzBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~r   )T)zpython-requests)jZ__doc__r   Z
contextlibr=   r:   r(   r   r   ZsysrZ   r;   rY   Zcollectionsr    Zpip._vendor.urllib3.utilr   r   r   r   r   Z_internal_utilsr   r   r   r	   Zcompatr
   r   r   r   r   r   r   rf   r   r   r   r   r   r   r   Zcookiesr   Z
exceptionsr   r   r   r   Z
structuresr   rK   ZwhereZDEFAULT_CA_BUNDLE_PATHZDEFAULT_PORTSrX   r&   r   Zplatformr-   r2   r@   rR   rV   r\   Zcontextmanagerr[   ra   rb   rl   rn   rg   rt   ru   rx   r   r   r   r   r   Z	frozensetr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r9   r   r   r   r   r   r   r   r   r   r   rA   r/   r,   <module>r      s     	 	 	   
    # <  $   :   )  ," Wc* ))HHWl489JKL 
 <<7$L	/B3J6r&"J 	 	6<@F202%22"$P M
05,550 1 1*:z	46#"L 	g		@C: ,
&A"Sr/   