o
    ê}”eÈ  ã                   @  sâ   d dl mZ d dlZd dlZd dlmZ ddlmZ ddlm	Z	 ddlm
Z
 ddlmZ dd	lmZ dd
lmZ e d¡Z									d,d-dd„ZejdejejB d�Ze d¡Zd.d#d$„Z		d/d0d)d*„Zdd+lmZ dS )1é    )ÚannotationsN)Údatetimeé   )Ú
_dt_as_utc)Úgenerate_etag)Ú
parse_date)Úparse_etags)Úparse_if_range_header)Úunquote_etagz&([Ww]/)?(?:"(.*?)"|(.*?))(?:\s*,\s*|$)TÚ
http_rangeú
str | NoneÚhttp_if_rangeÚhttp_if_modified_sinceÚhttp_if_none_matchÚhttp_if_matchÚetagÚdataúbytes | NoneÚlast_modifiedúdatetime | str | NoneÚignore_if_rangeÚboolÚreturnc	                 C  s  |du r|durt |ƒ}n|durtdƒ‚d}	t|tƒr t|ƒ}|dur,t|jdd�ƒ}d}
|s8| dur8t|ƒ}
|
durE|
jdurE|
j}nt|ƒ}|rS|rS||krSd}	|rŒt	|ƒ\}}t
 t|¡}|
duru|
jdurut|
jƒ |¡}	|	 S t|ƒ}|r€| |¡}	t|ƒ}|rŒ| |¡ }	|	 S )a  Convenience method for conditional requests.
    :param http_range: Range HTTP header
    :param http_if_range: If-Range HTTP header
    :param http_if_modified_since: If-Modified-Since HTTP header
    :param http_if_none_match: If-None-Match HTTP header
    :param http_if_match: If-Match HTTP header
    :param etag: the etag for the response for comparison.
    :param data: or alternatively the data of the response to automatically
                 generate an etag using :func:`generate_etag`.
    :param last_modified: an optional date of the last modification.
    :param ignore_if_range: If `False`, `If-Range` header will be taken into
                            account.
    :return: `True` if the resource was modified, otherwise `False`.

    .. versionadded:: 2.2
    Nzboth data and etag givenFr   )ÚmicrosecondT)r   Ú	TypeErrorÚ
isinstanceÚstrr   r   Úreplacer	   Údater
   ÚtÚcastr   r   ÚcontainsZcontains_weakZ	is_strong)r   r   r   r   r   r   r   r   r   Z
unmodifiedZif_rangeZmodified_sinceÚ_Zif_none_matchZif_match© r#   ú]/Users/abhinavbhinder/Documents/map/venv/lib/python3.10/site-packages/werkzeug/sansio/http.pyÚis_resource_modified   s<   

ò
r%   zr
    ([^=;]*)
    (?:\s*=\s*
      (
        "(?:[^\\"]|\\.)*"
      |
        .*?
      )
    )?
    \s*;\s*
    )Úflagss   \\([0-3][0-7]{2}|.)Úmút.Match[bytes]Úbytesc                 C  s,   |   d¡}t|ƒdkr|S t|dƒ dd¡S )Né   é   Úbig)ÚgroupÚlenÚintÚto_bytes)r'   Úvr#   r#   r$   Ú_cookie_unslash_replacer   s   
r2   ÚcookieÚclsútype[ds.MultiDict] | Noneúds.MultiDict[str, str]c                 C  s²   |du rt j}| s|ƒ S | › d�} g }t | ¡D ]<\}}| ¡ }| ¡ }|s'qt|ƒdkrM|d |d   kr;dkrMn nt t|dd…  	¡ ¡j
dd	�}| ||f¡ q||ƒS )
a)  Parse a cookie from a string.

    The same key can be provided multiple times, the values are stored
    in-order. The default :class:`MultiDict` will have the first value
    first, and all values can be retrieved with
    :meth:`MultiDict.getlist`.

    :param cookie: The cookie header as a string.
    :param cls: A dict-like class to store the parsed cookies in.
        Defaults to :class:`MultiDict`.

    .. versionchanged:: 3.0
        Passing bytes, and the ``charset`` and ``errors`` parameters, were removed.

    .. versionadded:: 2.2
    Nú;r   r   éÿÿÿÿú"r*   r   )Úerrors)ÚdsZ	MultiDictÚ
_cookie_reÚfindallÚstripr.   Ú_cookie_unslash_reÚsubr2   ÚencodeÚdecodeÚappend)r3   r4   ÚoutZckÚcvr#   r#   r$   Úparse_cookie{   s&   
,ÿþrF   )Údatastructures)	NNNNNNNNT)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r'   r(   r   r)   )NN)r3   r   r4   r5   r   r6   )Ú
__future__r   ÚreÚtypingr   r   Ú	_internalr   Úhttpr   r   r   r	   r
   ÚcompileZ_etag_rer%   ÚASCIIÚVERBOSEr<   r?   r2   rF   Ú rG   r;   r#   r#   r#   r$   Ú<module>   s>    
÷P
ô


þ0