o
    L)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 SettingsProxyEnableProxyOverride;z<local>.Tz\.*z.*?)winregImportErrorOpenKeyHKEY_CURRENT_USERintQueryValueExOSError
ValueErrorsplitfilterreplacerematchI)r>   rG   internetSettingsproxyEnableproxyOverridetest rY   s/var/www/html/finance-dev.cargoinsureonline.com/_shared/backend-venv/lib/python3.10/site-packages/requests/utils.pyproxy_bypass_registryc   s<   

r[   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   r[   )r>   rY   rY   rZ   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)r\   rY   rY   rZ   dict_to_sequence   s   
rb   or   rK   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   r_   r    encodehasattrrf   rg   ioUnsupportedOperationAttributeErrorosfstatst_sizemodewarningswarnr'   ri   rM   rj   max)rc   total_lengthcurrent_positionrg   rY   rY   rZ   	super_len   sN   






rz   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.rd   NETRCNc                 s  s    | ]}d | V  qdS )z~/NrY   ).0frY   rY   rZ   	<genexpr>   s    z!get_netrc_auth.<locals>.<genexpr>r   )NetrcParseErrornetrcr    rk   )r_   r   decoderq   environgetr3   r   r   path
expanduserexistsr"   hostnameauthenticatorsanyrM   rH   rp   )r{   r}   
netrc_filenetrc_locationsr   r   
netrc_pathr   locrir>   r2   login_irY   rY   rZ   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   <>)getattrr_   r    r   rq   r   basename)r   r   rY   rY   rZ   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)rq   r   r   rO   joinzipfile
is_zipfileZipFilenamelistsplitexttempfilemkstempwritereadclose)r   archivememberprefixzip_filer   fdextracted_pathrY   rY   rZ   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   rq   r   dirnamefdopenrQ   BaseExceptionremove)r   tmp_descriptortmp_nametmp_handlerrY   rY   rZ   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)r_   r    r   r@   rK   rN   r   r   rY   rY   rZ   from_key_val_listU  s
   r   Nonec                 C     d S NrY   r   rY   rY   rZ   to_key_val_listr  s   r   6_t.SupportsItems[_KT, _VT] | Iterable[tuple[_KT, _VT]]list[tuple[_KT, _VT]]c                 C  r   r   rY   r   rY   rY   rZ   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   )	r_   r    r   r@   rK   rN   r`   listra   r   rY   rY   rZ   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itemrY   rY   rZ   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   rO   r   )r   r   r   r   rY   rY   rZ   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   Nrk   z\\\z\")rQ   )r   r   rY   rY   rZ   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 rY   )r   r   )r   cookierY   rY   rZ   
<dictcomp>  s    z'dict_from_cookiejar.<locals>.<dictcomp>rY   r   cookie_dictrY   rY   rZ   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   rY   rY   rZ   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=["\']*(.+?)["\'>])ru   rv   DeprecationWarningrR   compilerT   findall)r   
charset_re	pragma_rexml_rerY   rY   rZ   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.
    rC   r   r   Nz"' r   r   )rO   stripfindlower)
r   tokenscontent_typeparamsparams_dictstrip_charsparamidxkeyr   rY   rY   rZ   _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/jsonrd   )r   r   r   )r   r   r   rY   rY   rZ   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.NrQ   errors    T)final)encodingcodecsgetincrementaldecoderr   )r   r  decoderchunkrvrY   rY   rZ   stream_decode_response_unicodeR  s   



r  stringr   slice_length
int | NoneGenerator[bytes, None, None]c                 C  r   r   rY   r  r  rY   rY   rZ   iter_slicese  r   r  Generator[str, None, None]c                 C  r   r   rY   r  rY   rY   rZ   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)rf   )r  r  posrY   rY   rZ   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.)Nrd   rQ   r  )
ru   rv   r   r   r   r   r    UnicodeErrorr   	TypeError)r  tried_encodingsr  rY   rY   rZ   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   rk      z"Invalid percent-escape sequence: ''Nr   )
rO   rangerf   isalnumchrrK   rN   r)   r  r   )r  partsihcrY   rY   rZ   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_percentrY   rY   rZ   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_atonrO   dotted_netmaskrK   )r/  r0  ipaddrnetaddrbitsnetmasknetworkrY   rY   rZ   address_in_network  s
   r;  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)r3  	inet_ntoar1  pack)r<  r8  rY   rY   rZ   r5    s   r5  	string_ipc                 C  s&   zt |  W dS  ty   Y dS w )z
    :rtype: bool
    FT)r3  r4  rM   )r@  rY   rY   rZ   is_ipv4_address  s   rA  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   Fr=  r   T)countrK   rO   rN   r3  r4  rM   )rB  r<  rY   rY   rZ   is_valid_cidr  s   rD  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)rq   r   r   )rE  r   value_changed	old_valuerY   rY   rZ   set_environ  s    
rI  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   )rq   r   r   upper)r   rY   rY   rZ   	get_proxy3  s   z(should_bypass_proxies.<locals>.get_proxyNrJ  Tc                 s  s    | ]}|r|V  qd S r   rY   )r   r>   rY   rY   rZ   r   E  s    z(should_bypass_proxies.<locals>.<genexpr> r   ,:rD   F)r   r    r?   r   )r"   r   rQ   rO   rA  rD  r;  portlstripendswithrI  r   r  r3  gaierror)r{   rJ  rL  no_proxy_argparsedr   no_proxy_hostsproxy_iphost_with_portr>   bypassrY   rY   rZ   should_bypass_proxies*  sT   
	
	
rZ  c                 C  s   t | |dri S t S )zA
    Return a dict of environment proxies.

    :rtype: dict
    rJ  )rZ  r   )r{   rJ  rY   rY   rZ   get_environ_proxiesi  s   r\  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)r{   r]  urlparts
proxy_keysproxy	proxy_keyrY   rY   rZ   select_proxyu  s"   
re  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
    NrJ  r[  r_  )
r
   r    r{   r"   r`  r   copyrZ  r\  
setdefault)	rf  r]  rh  r{   r`  rJ  new_proxiesenviron_proxiesrc  rY   rY   rZ   resolve_proxies  s   

rm  python-requestsr   c                 C  s   |  dt  S )zO
    Return a string representing the default user agent.

    :rtype: str
    r   r   )r   rY   rY   rZ   default_user_agent  s   ro  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+   ro  r<   rY   rY   rY   rZ   default_headers  s   rr  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, *<rC   r   r   r{   z<> '"r   )r   rR   rO   rN   r   )	r   linksreplace_charsvalr{   r   linkr   r   rY   rY   rZ   parse_header_links  s*   
rx   asciirk      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-32r{  z	utf-8-sigrk   zutf-16r   rd   z	utf-16-ber   z	utf-16-lez	utf-32-bez	utf-32-le)
r	  BOM_UTF32_LEBOM_UTF32_BEBOM_UTF8BOM_UTF16_LEBOM_UTF16_BErC  _null_null2_null3)r|  sample	nullcountrY   rY   rZ   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#   )r{   r  rU  r`  auth_host_portr   queryfragmentr  rY   rY   rZ   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passwordrp   r  )r{   rU  r  rY   rY   rZ   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   rY   rY   rZ   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: )r_   r    r   r   r   r(   typerS   )r   r  r  	validatorheader_kindrY   rY   rZ   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#   )r{   r`  r  r   r   r  	_fragmentrY   rY   rZ   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.
    rj   Nz;An error occurred when rewinding request body for redirect.z+Unable to rewind request body for redirect.)r   bodyr_   _body_positionr   rM   r*   )r  	body_seekrY   rY   rZ   rewind_bodys  s   
r  )r>   r    r?   r@   )r\   r]   r?   r^   )rc   r   r?   rK   )F)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   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    r0  r    r?   r@   )r<  rK   r?   r    )r@  r    r?   r@   )rB  r    r?   r@   )rE  r    r   r   r?   rF  )r{   r    rJ  r   r?   r@   r   )r{   r    rJ  r   r?   r   )r{   r    r]  r^  r?   r   )T)rf  rg  r]  r^  rh  r@   r?   r   )rn  )r   r    r?   r    )r?   r   )r   r    r?   rs  )r|  r   r?   r   )r{   r    r  r    r?   r    )r{   r    r?   r  )r   r  r?   r   )r   r  r  r  r  rK   r?   r   )r{   r    r?   r    )r  r/   r?   r   )__doc__
__future__r   r	  
contextlibrn   rq   rR   r3  r1  sysr   ru   r   collectionsr   collections.abcr   r   typingr   r   r   r	   r
   r   urllib3.utilr   r   r   r   r   _internal_utilsr   r   r   r   r.   r   r`   compatr   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r   cookiesr&   
exceptionsr'   r(   r)   r*   
structuresr+   http.cookiejarr,   r-   _tmodelsr/   r0   r1   r3   __annotations__wherer4   r8   r9   r:   r   rO   r<   platformr[   rb   rz   r   r   r   contextmanagerr   r   r   r   r   r   r   r   r   r   r   r  r  r  	frozensetr  r*  r.  r;  r5  rA  rD  rI  rZ  r\  re  rm  ro  rr  rx  rl   r  r  r  r  r  r  r  r  r  r  rY   rY   rY   rZ   <module>   s     	<

&

H
4
&


 
 #







*






?

	

&

 