
     fS                     f   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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l0m1Z1 dZ2 ej3                    Z4dddZ5d6                     ej7        d ed          d                             Z8ej9        dk    rd Z:d Z"d Z;d Z<dJdZ=d Z>d  Z?ej@        d!             ZAd" ZBd# ZCd$ ZDd% ZEdJd&ZFd' ZGd( ZHd) ZId* ZJd+ ZKd, ZLd- ZMd. ZN eOd/          ZPd0 ZQd1 ZRd2 ZSd3 ZTd4 ZUd5 ZVej@        d6             ZWd7 ZXdKd8ZYd9 ZZdLd:Z[dMd<Z\d= Z]d> Z^d?_                    d@          Z`e`dAz  Zae`dBz  ZbdC ZcdD ZddE ZedF ZfdG ZgdH ZhdI Zid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_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)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          }t          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filterreplacerematchI)hostr0   internetSettingsproxyEnableproxyOverridetests         Q/var/www/api.educacionweb.es/myenv/lib/python3.11/site-packages/requests/utils.pyproxy_bypass_registryrD   L   s   	MMMM 	 	 	55	
	%~~(N   
 f112BMRRSTUVVK"//0@/RRSTUMM$ 	 	 	55	 	- 	5
 &++C00t]33! 	 	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   rD   )r>   s    rC   r   r   r   s.     "## 	/+D111(...    c                 N    t          | d          r|                                 } | S )z/Returns an internal sequence dictionary update.items)hasattrrH   )ds    rC   dict_to_sequencerK   ~   s(     q' GGIIHrF   c                 :   d }d}t          | t                    r|                     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   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   )
isinstancer   encoderI   rO   rP   osfstatst_sizemodewarningswarnr   ioUnsupportedOperationAttributeErrorrR   rS   r6   max)ototal_lengthcurrent_positionrP   s       rC   	super_lenrd      s   L!S HHW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   8C	 	C"!C"6E2 AE E.-E.2FF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     rC   	<genexpr>z!get_netrc_auth.<locals>.<genexpr>   s(      99888999999rF   r   )NetrcParseErrornetrc   :asciir   rT   )rW   environgetNETRC_FILESrm   rl   path
expanduserKeyErrorexistsr   rU   r   decodenetlocr8   authenticatorsr6   r1   r_   )urlraise_errors
netrc_filenetrc_locationsrl   rm   
netrc_pathrj   locrisplitstrr>   r#   login_is                 rC   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   <>)getattrrU   r   rW   rs   basename)objr   s     rC   guess_filenamer     sw    3%%D &
4,, &aCDHPSOOw%%%& & & &OOrF   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)rW   rs   rv   r8   joinzipfile
is_zipfileZipFilenamelisttempfile
gettempdiratomic_openwriteread)rs   archivememberprefixzip_filetmpextracted_pathfile_handlers           rC   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   mkstemprW   rs   dirnamefdopenr:   BaseExceptionremove)filenametmp_descriptortmp_nametmp_handlers       rC   r   r   1  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)rU   r   r   boolr4   r7   r   values    rC   from_key_val_listr   >  sG    $ }t%#udC011 HFGGGurF   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   )	rU   r   r   r   r4   r7   r   rH   listr   s    rC   to_key_val_listr   Y  sd    " }t%#udC011 HFGGG%!! ;;rF   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      rC   parse_list_headerr   w  s    . F"5))  8tBCCy''''C''''''QrT
33DdMrF   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   r8   r   )r   r   r   r   s       rC   parse_dict_headerr     s    , F"5))  d??F4Ljja((e!9bcc
))))c)))))(qt55EtMrF   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   NrT   z\\\z\")r:   )r   is_filenames     rC   r   r     s      CqU2Y----#-----
 ad  	CeBQBi611==..66ucBBBLrF   c                     d | D             }|S )zReturns a key/value dictionary from a CookieJar.

    :param cj: CookieJar object to extract cookies from.
    :rtype: dict
    c                 (    i | ]}|j         |j        S rh   )r   r   )ri   cookies     rC   
<dictcomp>z'dict_from_cookiejar.<locals>.<dictcomp>  s    >>>6;>>>rF   rh   cjcookie_dicts     rC   dict_from_cookiejarr     s     ?>2>>>KrF   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   s     rC   add_dict_to_cookiejarr     s     {B///rF   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=["\']*(.+?)["\'>])r[   r\   DeprecationWarningr;   compiler=   findall)content
charset_re	pragma_rexml_res       rC   get_encodings_from_contentr     s    
 M1 	   @MMMJ
IQSQUVVVIZ?@@F 	7##


G
$
$	%
..
!
!	"rF   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   )r8   stripfindlower)
headertokenscontent_typeparamsparams_dictitems_to_stripparamkeyr   index_of_equalss
             rC   _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		$$$rF   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/jsonrM   )rq   r   r   )headersr   r   s      rC   get_encoding_from_headersr     s     ;;~..L t5lCCL&Fi &&u---|\))w *)rF   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.Nr:   errorsrF   T)final)encodingcodecsgetincrementaldecoderrw   )iteratorrdecoderchunkrvs        rC   stream_decode_response_unicoder   4  s       	z6f*1:66iHHHG  ^^E"" 	HHH	4	(	(B	  rF   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)rO   )stringslice_lengthposs      rC   iter_slicesr   E  s{      
C|q006{{
F

S3--....| F





rF   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.)r:   r   )
r[   r\   r   r   r   r   r   UnicodeErrorr   	TypeError)r   tried_encodingsr   s      rC   get_unicode_from_responser  O  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   rT      z"Invalid percent-escape sequence: ''N )
r8   rangerO   isalnumchrr4   r7   r    UNRESERVED_SETr   )uripartsihcs        rC   unquote_unreservedr  |  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      rC   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_atonr8   dotted_netmaskr4   )ipnetipaddrnetaddrbitsnetmasknetworks          rC   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4rF   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     rC   r  r    s8     b4i1,,DFKd33444rF   c                 T    	 t          j        |            n# t          $ r Y dS w xY wdS )z
    :rtype: bool
    FT)r  r  r6   )	string_ips    rC   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)countr4   r8   r7   r  r  r6   )string_networkr(  s     rC   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)rW   rp   rq   )env_namer   value_changed	old_values       rC   set_environr4    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)rW   rp   rq   upper)r   s    rC   	get_proxyz(should_bypass_proxies.<locals>.get_proxy  s1    z~~c""AbjnnSYY[[&A&AArF   Nno_proxyTc              3      K   | ]}||V  	d S r7  rh   )ri   r>   s     rC   rk   z(should_bypass_proxies.<locals>.<genexpr>  s'      RRTTRDRRRRRRrF    r  ,:F)r   hostnamer:   r8   r+  r/  r#  portendswithr4  r   r   r  gaierror)	rz   r:  r9  no_proxy_argparsedproxy_iphost_with_portr>   bypasss	            rC   should_bypass_proxiesrH    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
    r:  )rH  r   )rz   r:  s     rC   get_environ_proxiesrK  :  s(     S8444 	||rF   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   r?  rq   scheme)rz   proxiesurlparts
proxy_keysproxy	proxy_keys         rC   select_proxyrT  F  s     mG}}H {{8?GKK,>,>??? 	%("338$$	J E  	I&EE   LrF   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 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
    Nr:  rJ  rM  )rz   r   rN  rq   copyrH  rK  
setdefault)	requestrO  	trust_envrz   rN  r:  new_proxiesenviron_proxiesrR  s	            rC   resolve_proxiesr\  `  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rF   python-requestsc                     |  dt            S )zO
    Return a string representing the default user agent.

    :rtype: str
    r   r   )r   s    rC   default_user_agentr_  {  s     ""["""rF   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"   r_  DEFAULT_ACCEPT_ENCODINGrh   rF   rC   default_headersrd    s2     ,..6&		
 	
  rF   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  rz   z<> '"r   )r   r;   r8   r7   r   )	r   linksreplace_charsvalrz   r   linkr   r   s	            rC   parse_header_linksrj    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: ro   rT      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-32rl  z	utf-8-sigrT   zutf-16r   rM   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      rC   guess_json_utfrz    s    "1"XF&%v':;;;xbqbzV_$${bqbzf)6+>???xU##IA~~wA~~##A#;&  ;!$Q$<6!!;A~~"1":;!"":;4rF   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   rx   r   r   )rz   
new_schemerD  rN  authr>   r@  rs   queryfragmentrx   s              rC   prepend_scheme_if_neededr    s     s^^F6<3FD$dE8 ]F $V * 4.))~|vvtRABBBrF   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passwordr_   r   )rz   rD  r~  s      rC   get_auth_from_urlr    sd     c]]F(('&/*B*BCI&    Ks   (: AAc                 T    | \  }}t          | |d           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).
    r   r   N)_validate_header_part)r   r   r   s      rC   check_header_validityr  
  s7     KD%&$***&%+++++rF   c           
      D   t          |t                    rt          |         }nHt          |t                    rt          |         }n%t          d|d|  dt          |                     |                    |          s|dk    rdnd}t          d| d|          d S )	NzHeader part (z) from z# must be of type str or bytes, not r   r   r   zTInvalid leading whitespace, reserved character(s), or return character(s) in header z: )rU   r   r   r   r
   r   typer<   )r   header_partheader_validator_index	validatorheader_kinds        rC   r  r    s    +s## 
*+AB			K	'	' 
+,BC		EK E E& E E15k1B1BE E
 
 	

 ??;'' 
 6! ; ;ffE&1E E5@E E
 
 	

 
rF   c                     t          |           \  }}}}}}|s||}}|                    dd          d         }t          |||||df          S )zW
    Given a url remove the fragment and the authentication part.

    :rtype: str
    r|  r   r   r  )r   rsplitr   )rz   rN  rx   rs   r   r  r  s          rC   urldefragauthr  (  sb     5=SMM1FFD&%  $V]]3""2&FvvtVUB?@@@rF   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.
    rS   Nz;An error occurred when rewinding request body for redirect.z+Unable to rewind request body for redirect.)r   bodyrU   _body_positionr   r6   r!   )prepared_request	body_seeks     rC   rewind_bodyr  9  s     (-vt<<I'" "	I&566666 	 	 	'M  	
 $$QRRRs   A A )Fr7  )T)r]  )j__doc__r   
contextlibr]   rW   r;   r  r  sysr   r[   r   collectionsr   urllib3.utilr   r   r  r   r	   _internal_utilsr
   r   r   r   compatr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   cookiesr   
exceptionsr   r   r    r!   
structuresr"   rr   whereDEFAULT_CA_BUNDLE_PATHDEFAULT_PORTSr   r8   rc  platformrD   rK   rd   r   r   r   contextmanagerr   r   r   r   r   r   r   r   r   r   r   r   r   r  	frozensetr
  r  r  r#  r  r+  r/  r4  rH  rK  rT  r\  r_  rd  rj  rV   rt  ru  rv  rz  r  r  r  r  r  r  rh   rF   rC   <module>r     s         				 				 				   



    # # # # # # 0 0 0 0 0 0 0 0       $ $ $ $ $ $                           : 9 9 9 9 9                  ) ( ( ( ( (            , + + + + +"$ c** ))BHWll48889JKLL  
 <7$ $ $L	/ 	/ 	/  B3 B3 B3J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*: : :z	 	 	 	  4   6# # # #  " " "L 	g		  @C C C:   , , ,
 
 
&A A A"S S S S SrF   