o
    #j                     @  sB  U d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddlZddlmZ ddlmZmZ ddlmZmZmZmZmZmZ ddlmZmZ dd	lmZ dd
lmZ ddl m!Z!m"Z"m#Z#m$Z$ ddl%m&Z' ddl(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5 ddl(m6Z7 ddl8m9Z9 ddl:m;Z;m<Z<m=Z=m>Z> ddl?m@Z@ erddlAmBZB ddlmCZC ddlm%ZD ddlEmFZFmGZGmHZH dZIdeJd< eK ZLdeJd< dddZMdeJd< edZNed ZOd!PeQd"ed#d$d% ZRdeJd&< e
jSd'krdd+d,ZTdd-d.Z/dd2d3ZUdd7d8ZV	9ddd>d?ZWddBdCZXddEdFZYejZddIdJZ[ddNdOZ\eddQdRZ]eddUdRZ]ddXdRZ]ddZd[Z^dd]d^Z_ddd`daZ`ddddeZaddhdiZbddkdlZcddodpZdddsdtZeddzd{ZfedddZgedddZgdddZgdddZheidZjdeJd< dddZkdddZldddZmdddZndddZodddZpejZdddZqdddZrddddZsdddZt	#ddddZuddddZvdddZwdddZxdydZzezd Z{ezd Z|dddZ}dddÄZ~d ddƄZdddɄZddd΄ZdddЄZdddԄZdS (  z
requests.utils
~~~~~~~~~~~~~~

This module provides utility functions that are used within Requests
that are also useful for external consumption.
    )annotationsN)OrderedDict)	GeneratorIterable)TYPE_CHECKINGAnyFinalTypeVarcastoverload)make_headers	parse_url   )certs__version__)_HEADER_VALIDATORS_BYTE_HEADER_VALIDATORS_STRHEADER_VALIDATORSto_native_string)SupportsItems)Mappingbytes
getproxiesgetproxies_environmentinteger_typesis_urllib3_1proxy_bypassproxy_bypass_environmentquotestrunquoteurlparse
urlunparse)parse_http_listcookiejar_from_dict)FileModeWarningInvalidHeader
InvalidURLUnrewindableBodyError)CaseInsensitiveDict)	CookieJar)BufferedWriter)_types)PreparedRequestRequestResponse)z.netrc_netrcr   NETRC_FILESr    DEFAULT_CA_BUNDLE_PATHP   i  )httphttpsDEFAULT_PORTS_KT_VTz, z,\s*T)accept_encodingzaccept-encodingDEFAULT_ACCEPT_ENCODINGwin32hostreturnboolc              	   C  s   zdd l }W n
 ty   Y dS w z||jd}t||dd }||dd }W n ttfy8   Y dS w |r=|s?dS |d}t	d |}|D ]*}|dkrXd| vrX d	S |
dd
}|
dd}|
dd}t|| tjru d	S qKdS )Nr   Fz;Software\Microsoft\Windows\CurrentVersion\Internet SettingsZProxyEnableZProxyOverride;z<local>.Tz\.*z.*?)winregImportErrorOpenKeyHKEY_CURRENT_USERintQueryValueExOSError
ValueErrorsplitfilterreplacerematchI)r>   rE   ZinternetSettingsZproxyEnableZproxyOverridetest rT   O/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/requests/utils.pyproxy_bypass_registryc   s<   

rV   c                 C  s   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   rV   )r>   rT   rT   rU   r      s   r   d6_t.SupportsItems[Any, Any] | Iterable[tuple[Any, Any]]Iterable[tuple[Any, Any]]c                 C  s   t | tr	|  S | S )z/Returns an internal sequence dictionary update.)
isinstance_SupportsItemsitems)rW   rT   rT   rU   dict_to_sequence   s   
r]   or   rI   c              	   C  s8  d }d}t st| tr| d} t| drt| }n2t| dr#| j}n)t| drLz|  }W n tjt	fy:   Y nw t
|j}d| jvrLtdt t| drz|  }W n tyf   |d urd|}Y n)w t| d	r|d u rz| dd
 |  }| |pd W n ty   d}Y nw |d u rd}td|| S )Nr   utf-8__len__lenfilenoba%  Requests has determined the content-length for this request using the binary size of the file: however, the file has been opened in text mode (i.e. without the 'b' flag in the mode). This may lead to an incorrect content-length. In Requests 3.0, support will be removed for files in text mode.tellseek   )r   rZ   r    encodehasattrra   rb   ioUnsupportedOperationAttributeErrorosfstatst_sizemodewarningswarnr'   rd   rK   re   max)r^   total_lengthcurrent_positionrb   rT   rT   rU   	super_len   sN   






ru   Furl
_t.UriTyperaise_errorstuple[str, str] | Nonec              	   C  s8  t | tr
| d} tjd}|dur|f}ndd tD }zpddlm}m} d}|D ]}tj	
|}tj	|r>|} nq,|du rFW dS t| }	|	j}
|
du rTW dS z+|||
}|rxt|r||d rhdnd}|| pod	|d
 ptd	fW W S W W dS W W dS  |tfy   |r Y W dS w  ttfy   Y dS w )z;Returns the Requests tuple auth for a given url from netrc.r_   NETRCNc                 s  s    | ]}d | V  qdS )z~/NrT   ).0frT   rT   rU   	<genexpr>   s    z!get_netrc_auth.<locals>.<genexpr>r   )NetrcParseErrornetrcr    rf   )rZ   r   decoderl   environgetr3   r   r~   path
expanduserexistsr"   hostnameauthenticatorsanyrK   rF   rk   )rv   rx   
netrc_filenetrc_locationsr~   r   
netrc_pathr|   locrir>   r2   login_irT   rT   rU   get_netrc_auth   sF   

r   obj
str | Nonec                 C  sR   t | dd}|r!t|ttfr#|d dkr%|d dkr'tj|S dS dS dS dS )z0Tries to guess the filename of the given object.nameNr   <>)getattrrZ   r    r   rl   r   basename)r   r   rT   rT   rU   guess_filename  s   *r   r   c              	   C  s   t j| r| S t j| \}}|r2t j|s2t j|\}}|s#nd||g}|r2t j|rt|s9| S t|}|| vrF| S t j	|dd d }t
j|d\}}zt ||| W t | |S t | w )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)rl   r   r   rM   joinzipfile
is_zipfileZipFilenamelistsplitexttempfilemkstempwritereadclose)r   archivememberprefixzip_filer   fdextracted_pathrT   rT   rU   extract_zipped_paths"  s*   


r   filename%Generator[BufferedWriter, None, None]c                 c  sz    t jtj| d\}}z"t|d}|V  W d   n1 s"w   Y  t||  W dS  ty<   t|  w )z-Write a file to the disk in an atomic fashion)dirwbN)	r   r   rl   r   dirnamefdopenrO   BaseExceptionremove)r   tmp_descriptortmp_nametmp_handlerrT   rT   rU   atomic_openH  s   
r   value4Mapping[Any, Any] | Iterable[tuple[Any, Any]] | Nonedict[Any, Any] | Nonec                 C  s.   | du rdS t | ttttfrtdt| S )a  Take an object and test to see if it can be represented as a
    dictionary. Unless it can not be represented as such, return an
    OrderedDict, e.g.,

    ::

        >>> from_key_val_list([('key', 'val')])
        OrderedDict([('key', 'val')])
        >>> from_key_val_list('string')
        Traceback (most recent call last):
        ...
        ValueError: cannot encode objects that are not 2-tuples
        >>> from_key_val_list({'key': 'val'})
        OrderedDict([('key', 'val')])

    :rtype: OrderedDict
    N+cannot encode objects that are not 2-tuples)rZ   r    r   r@   rI   rL   r   r   rT   rT   rU   from_key_val_listU  s
   r   Nonec                 C     d S NrT   r   rT   rT   rU   to_key_val_listr  s   r   6_t.SupportsItems[_KT, _VT] | Iterable[tuple[_KT, _VT]]list[tuple[_KT, _VT]]c                 C  r   r   rT   r   rT   rT   rU   r   t     =_t.SupportsItems[_KT, _VT] | Iterable[tuple[_KT, _VT]] | Nonelist[tuple[_KT, _VT]] | Nonec                 C  sD   | du rdS t | ttttfrtdt | trt|  S t| S )a  Take an object and test to see if it can be represented as a
    dictionary. If it can be, return a list of tuples, e.g.,

    ::

        >>> to_key_val_list([('key', 'val')])
        [('key', 'val')]
        >>> to_key_val_list({'key': 'val'})
        [('key', 'val')]
        >>> to_key_val_list('string')
        Traceback (most recent call last):
        ...
        ValueError: cannot encode objects that are not 2-tuples

    :rtype: list
    Nr   )	rZ   r    r   r@   rI   rL   r[   listr\   r   rT   rT   rU   r   x  s   
	list[str]c                 C  sX   g }t | D ]#}|dd |dd   krdkr$n nt|dd }|| q|S )a  Parse lists as described by RFC 2068 Section 2.

    In particular, parse comma-separated lists where the elements of
    the list may include quoted-strings.  A quoted-string could
    contain a comma.  A non-quoted string could have quotes in the
    middle.  Quotes are removed automatically after parsing.

    It basically works like :func:`parse_set_header` just that items
    may appear multiple times and case sensitivity is preserved.

    The return value is a standard :class:`list`:

    >>> parse_list_header('token, "quoted value"')
    ['token', 'quoted value']

    To create a header from the :class:`list` again, use the
    :func:`dump_header` function.

    :param value: a string with a list header.
    :return: :class:`list`
    :rtype: list
    Nr   r   ")_parse_list_headerunquote_header_valueappend)r   resultitemrT   rT   rU   parse_list_header  s   (r   dict[str, str | None]c                 C  sx   i }t | D ]3}d|vrd||< q|dd\}} | dd | dd   kr+dkr5n nt| dd } | ||< q|S )a^  Parse lists of key, value pairs as described by RFC 2068 Section 2 and
    convert them into a python dict:

    >>> d = parse_dict_header('foo="is a fish", bar="as well"')
    >>> type(d) is dict
    True
    >>> sorted(d.items())
    [('bar', 'as well'), ('foo', 'is a fish')]

    If there is no value for a key it will be `None`:

    >>> parse_dict_header('key_without_value')
    {'key_without_value': None}

    To create a header from the :class:`dict` again, use the
    :func:`dump_header` function.

    :param value: a string with a dict header.
    :return: :class:`dict`
    :rtype: dict
    =Nr   r   r   )r   rM   r   )r   r   r   r   rT   rT   rU   parse_dict_header  s   (
r   is_filenamec                 C  s^   | r-| d | d   krdkr-n | S | dd } |r#| dd dkr-|  dd d	dS | S )
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   Nrf   z\\\z\")rO   )r   r   rT   rT   rU   r     s   "r   cjr,   c                 C  s   dd | D }|S )zReturns a key/value dictionary from a CookieJar.

    :param cj: CookieJar object to extract cookies from.
    :rtype: dict
    c                 S  s   i | ]}|j |jqS rT   )r   r   )r{   cookierT   rT   rU   
<dictcomp>  s    z'dict_from_cookiejar.<locals>.<dictcomp>rT   r   cookie_dictrT   rT   rU   dict_from_cookiejar  s   r   r   dict[str, str]c                 C  s
   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   rT   rT   rU   add_dict_to_cookiejar  s   
r   contentc                 C  sT   t dt tjdtjd}tjdtjd}td}|| ||  ||  S )zlReturns encodings from given content string.

    :param content: bytestring to extract encodings from.
    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=["\']*(.+?)["\'>])rp   rq   DeprecationWarningrP   compilerR   findall)r   
charset_re	pragma_rexml_rerT   rT   rU   get_encodings_from_content
  s   	
r   headertuple[str, dict[str, Any]]c           
      C  s   |  d}|d  |dd }}i }d}|D ]+}| }|rC|d }dkrC|d| |}||d d |}	|	|| < q||fS )zReturns content type and parameters from given header.

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

    :param headers: dictionary to extract encoding from.
    :rtype: str
    zcontent-typeNcharsetz'"textz
ISO-8859-1zapplication/jsonr_   )r   r   r   )r   r   r   rT   rT   rU   get_encoding_from_headers9  s   
r   iteratorIterable[bytes]rr1   "Generator[str | bytes, None, None]c                 c  sj    |j du r| E dH  dS t|j dd}| D ]}||}|r$|V  q|jddd}|r3|V  dS dS )zStream decodes an iterator.NrO   errors    T)final)encodingcodecsgetincrementaldecoderr   )r   r   decoderchunkrvrT   rT   rU   stream_decode_response_unicodeR  s   



r	  stringr   slice_length
int | NoneGenerator[bytes, None, None]c                 C  r   r   rT   r
  r  rT   rT   rU   iter_slicese  r   r  Generator[str, None, None]c                 C  r   r   rT   r  rT   rT   rU   r  i  r   bytes | str"Generator[bytes | str, None, None]c                 c  sX    d}|du s|dkrt | }|t | k r*| |||  V  ||7 }|t | k sdS dS )z Iterate over slices of a string.r   N)ra   )r
  r  posrT   rT   rU   r  m  s   str | bytes | Nonec                 C  s   t dt | jdu rdS g }t| j}|r,zt| j|W S  ty+   || Y nw zt| j|p3dddW S  t	yC   | j Y S w )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.)Nr_   rO   r   )
rp   rq   r   r   r   r   r    UnicodeErrorr   	TypeError)r   tried_encodingsr  rT   rT   rU   get_unicode_from_responsey  s&   


r  zBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~UNRESERVED_SETuric              	   C  s   |  d}tdt|D ]Q}|| dd }t|dkrT| rTz	tt|d}W n ty8   td| dw |tv rJ||| dd  ||< qd||  ||< qd||  ||< qd		|S )
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   rf      z"Invalid percent-escape sequence: ''Nr   )
rM   rangera   isalnumchrrI   rL   r)   r  r   )r  partsihcrT   rT   rU   unquote_unreserved  s   

r%  c                 C  s:   d}d}z	t t| |dW S  ty   t | |d Y S 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_percentrT   rT   rU   requote_uri  s   r)  ipnetc                 C  sl   t dt| d }|d\}}t dttt|d }t dt|d |@ }||@ ||@ kS )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_atonrM   dotted_netmaskrI   )r*  r+  ipaddrnetaddrbitsnetmasknetworkrT   rT   rU   address_in_network  s
   r6  maskc                 C  s&   ddd|  > d A }t t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)r7  r3  rT   rT   rU   r0    s   r0  	string_ipc                 C  s&   zt |  W dS  ty   Y dS w )z
    :rtype: bool
    FT)r.  r/  rK   )r;  rT   rT   rU   is_ipv4_address  s   r<  string_networkc                 C  s   |  ddkr?zt| dd }W n
 ty   Y dS w |dk s%|dkr'dS zt| dd  W dS  ty>   Y dS w dS )zV
    Very simple check of the cidr format in no_proxy variable.

    :rtype: bool
    r   r   Fr8  r   T)countrI   rM   rL   r.  r/  rK   )r=  r7  rT   rT   rU   is_valid_cidr  s   r?  env_nameGenerator[None, None, None]c              	   c  s~    |du}d}|rt j| }|t j| < zdV  W |r,|du r%t j| = dS |t j| < dS dS |r>|du r9t j| = w |t j| < w )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)rl   r   r   )r@  r   value_changed	old_valuerT   rT   rU   set_environ  s    
rD  no_proxyc              
   C  sZ  ddd}|}|du r|d}t | }|j}|du rd	S |r}d
d |dddD }t|rJ|D ]}t|rAt||r@ d	S q2||krH d	S q2n3|}|jrW|d|j 7 }|D ]#}	|	d}	||	ksh||	krk d	S d|	 }	|	|	sy|	|	r| d	S qYt
d| zt|}
W n ttjfy   d}
Y nw W d   n1 sw   Y  |
rd	S dS )zL
    Returns whether we should bypass proxies or not.

    :rtype: bool
    r   r    r?   r   c                 S  s   t j| pt j|  S r   )rl   r   r   upper)r   rT   rT   rU   	get_proxy3  s   z(should_bypass_proxies.<locals>.get_proxyNrE  Tc                 s  s    | ]}|r|V  qd S r   rT   )r{   r>   rT   rT   rU   r}   E  s    z(should_bypass_proxies.<locals>.<genexpr> r   ,:rB   F)r   r    r?   r   )r"   r   rO   rM   r<  r?  r6  portlstripendswithrD  r   r  r.  gaierror)rv   rE  rG  no_proxy_argparsedr   Zno_proxy_hostsproxy_iphost_with_portr>   bypassrT   rT   rU   should_bypass_proxies*  sT   
	
	
rT  c                 C  s   t | |dri S t S )zA
    Return a dict of environment proxies.

    :rtype: dict
    rE  )rT  r   )rv   rE  rT   rT   rU   get_environ_proxiesi  s   rV  proxiesdict[str, str] | Nonec                 C  sv   |pi }t | }|jdu r||j|dS |jd |j |jd|j dg}d}|D ]}||v r8|| } |S q+|S )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)rv   rW  urlparts
proxy_keysproxy	proxy_keyrT   rT   rU   select_proxyu  s"   
r_  requestRequest | PreparedRequest	trust_envc           	      C  sz   |dur|ni }t t| j}t|j}|d}| }|r;t||ds;t||d}|||d}|r;|	|| |S )a  This method takes proxy information from a request and configuration
    input to resolve a mapping of target proxies. This will consider settings
    such as NO_PROXY to strip proxy configurations.

    :param request: Request or PreparedRequest
    :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs
    :param trust_env: Boolean declaring whether to trust environment configs

    :rtype: dict
    NrE  rU  rY  )
r
   r    rv   r"   rZ  r   copyrT  rV  
setdefault)	r`  rW  rb  rv   rZ  rE  new_proxiesenviron_proxiesr]  rT   rT   rU   resolve_proxies  s   

rg  python-requestsr   c                 C  s   |  dt  S )zO
    Return a string representing the default user agent.

    :rtype: str
    r   r   )r   rT   rT   rU   default_user_agent  s   ri  c                   C  s   t t tdddS )z9
    :rtype: requests.structures.CaseInsensitiveDict
    z*/*z
keep-alive)z
User-AgentzAccept-EncodingAccept
Connection)r+   ri  r<   rT   rT   rT   rU   default_headers  s   rl  list[dict[str, str]]c           	   
   C  s   g }d}|  |} | s|S td| D ]M}z
|dd\}}W n ty-   |d}}Y nw d| di}|dD ] }z	|d\}} W n
 tyO   Y  nw |  ||| |< q:|| q|S )	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, *<rA   r   r   rv   z<> '"r   )r   rP   rM   rL   r   )	r   linksreplace_charsvalrv   r   linkr   r   rT   rT   rU   parse_header_links  s*   
rr   asciirf      datac                 C  s   | dd }|t jt jfv rdS |dd t jkrdS |dd t jt jfv r)dS |t}|dkr4d	S |dkrN|ddd tkrCd
S |ddd tkrNdS |dkrf|dd t	kr\dS |dd t	krfdS dS )z
    :rtype: str
    N   zutf-32ru  z	utf-8-sigrf   zutf-16r   r_   z	utf-16-ber   z	utf-16-lez	utf-32-bez	utf-32-le)
r  BOM_UTF32_LEBOM_UTF32_BEBOM_UTF8BOM_UTF16_LEBOM_UTF16_BEr>  _null_null2_null3)rv  sample	nullcountrT   rT   rU   guess_json_utf  s*   
r  
new_schemec                 C  sv   t | }|\}}}}}}}	|j}
|
s||
}
}|r%tt|
}
d||
g}
|du r+|}|du r1d}t||
|d||	fS )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   netlocr
   r    r   r#   )rv   r  rP  rZ  auth_hostZ_portr   queryfragmentr  rT   rT   rU   prepend_scheme_if_needed  s   

r  tuple[str, str]c              	   C  s@   t | }zt|jt|jf}W |S  ttfy   d}Y |S w )z{Given a url with authentication components, extract them into a tuple of
    username,password.

    :rtype: (str,str)
    )r   r   )r"   r!   usernamepasswordrk   r  )rv   rP  r  rT   rT   rU   get_auth_from_url.  s   r  tuple[str | bytes, str | bytes]c                 C  s$   | \}}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   rT   rT   rU   check_header_validity?  s   r  header_partstr | bytesheader_validator_indexc                 C  sx   t |tr
t| }nt |trt| }ntd|d|  dt| ||s:|dkr.dnd}td| d|d S )	NzHeader part (z) from z# must be of type str or bytes, not r   r   r   zTInvalid leading whitespace, reserved character(s), or return character(s) in header z: )rZ   r    r   r   r   r(   typerQ   )r   r  r  	validatorheader_kindrT   rT   rU   r  J  s&   




r  c                 C  sF   t | \}}}}}}|s||}}|ddd }t|||||dfS )zW
    Given a url remove the fragment and the authentication part.

    :rtype: str
    r  r   r   r   )r"   rsplitr#   )rv   rZ  r  r   r   r  Z	_fragmentrT   rT   rU   urldefragauthb  s
   
r  prepared_requestr/   c                 C  sR   t | jdd}|dur%t| jtr%z|| j W dS  ty$   tdw td)zfMove file pointer back to its recorded starting position
    so it can be read again on redirect.
    re   Nz;An error occurred when rewinding request body for redirect.z+Unable to rewind request body for redirect.)r   bodyrZ   _body_positionr   rK   r*   )r  	body_seekrT   rT   rU   rewind_bodys  s   
r  )r>   r    r?   r@   )rW   rX   r?   rY   )r^   r   r?   rI   )F)rv   rw   rx   r@   r?   ry   )r   r   r?   r   )r   r    r?   r    )r   r    r?   r   )r   r   r?   r   )r   r   r?   r   )r   r   r?   r   )r   r   r?   r   )r   r    r?   r   )r   r    r?   r   )r   r    r   r@   r?   r    )r   r,   r?   r   )r   r,   r   r   r?   r,   )r   r    r?   r   )r   r    r?   r   )r   r   r?   r   )r   r   r   r1   r?   r   )r
  r   r  r  r?   r  )r
  r    r  r  r?   r  )r
  r  r  r  r?   r  )r   r1   r?   r  )r  r    r?   r    )r*  r    r+  r    r?   r@   )r7  rI   r?   r    )r;  r    r?   r@   )r=  r    r?   r@   )r@  r    r   r   r?   rA  )rv   r    rE  r   r?   r@   r   )rv   r    rE  r   r?   r   )rv   r    rW  rX  r?   r   )T)r`  ra  rW  rX  rb  r@   r?   r   )rh  )r   r    r?   r    )r?   r   )r   r    r?   rm  )rv  r   r?   r   )rv   r    r  r    r?   r    )rv   r    r?   r  )r   r  r?   r   )r   r  r  r  r  rI   r?   r   )rv   r    r?   r    )r  r/   r?   r   )__doc__
__future__r   r  
contextlibri   rl   rP   r.  r,  sysr   rp   r   collectionsr   collections.abcr   r   typingr   r   r   r	   r
   r   Z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-   Z_tmodelsr/   r0   r1   r3   __annotations__wherer4   r8   r9   r:   r   rM   r<   platformrV   r]   ru   r   r   r   contextmanagerr   r   r   r   r   r   r   r   r   r   r   r	  r  r  	frozensetr  r%  r)  r6  r0  r<  r?  rD  rT  rV  r_  rg  ri  rl  rr  rg   r}  r~  r  r  r  r  r  r  r  r  rT   rT   rT   rU   <module>   s     	<

&

H
4
&


 
 #







*






?

	

&

 