o
    
¨Ýj@  ã                   @  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 									d+d,dd„ZejdejejB d�Ze d¡Zd-d"d#„Z		d.d/d(d)„Zdd*lmZ dS )0é    )ÚannotationsN)Údatetimeé   )Ú
_dt_as_utc)Úgenerate_etag)Ú
parse_date)Úparse_etags)Úparse_if_range_header)Úunquote_etagTÚ
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dt |ƒ› d�}n|durtdƒ‚d}	t|tƒr$t|ƒ}|dur0t|jdd�ƒ}d}
|s<| dur<t|ƒ}
|
durI|
jdurI|
j}nt|ƒ}|rW|rW||krWd}	|r‡t	|ƒ\}}|
durp|
j
durp|
j
|k}	|	 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
    Nú"zboth data and etag givenFr   )ÚmicrosecondT)r   Ú	TypeErrorÚ
isinstanceÚstrr   r   Úreplacer	   Údater
   r   r   Z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!   úO/var/www/html/chatgpt/venv/lib/python3.10/site-packages/werkzeug/sansio/http.pyÚis_resource_modified   s:   

ò
r#   ah  
    [ \t]*  # ignore leading space
    ([^ \t=";]+)  # key
    (?:[ \t]*=[ \t]*  # optional =value, ignoring invalid space
        (
            "(?:[^\\"]|\\.)*"  # quoted value with backslash escapes
        |
            [^ \t";]*  # token value
        )
    )?
    [ \t]*  # ignore trailing space
    (?:;|\Z)  # only if followed by semicolon or end
    )Ú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_replaceq   s   
r0   ÚcookieÚclsú#type[ds.MultiDict[str, str]] | Noneúds.MultiDict[str, str]c                 C  sÆ   |du rt  dtj¡}| s|ƒ S g }d}	 t | |¡ }du r1|  d|¡d  }dkr0	 ||ƒS q| ¡ \}}| ¡ }|du rAd}| 	d¡r[| 
d¡r[t t|dd	…  ¡ ¡jd
d�}| ||f¡ q)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
    Nztype[ds.MultiDict[str, str]]r   Tú;r(   Ú r   éÿÿÿÿr   )Úerrors)ÚtÚcastÚdsZ	MultiDictÚ
_cookie_reÚmatchÚfindÚgroupsÚendÚ
startswithÚendswithÚ_cookie_unslash_reÚsubr0   ÚencodeÚdecodeÚappend)r1   r2   ÚoutÚposr%   ZckZcvr!   r!   r"   Úparse_cookiez   s0   ðÿþìrJ   )Ú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)r1   r   r2   r3   r   r4   )Ú
__future__r   ÚreÚtypingr9   r   Ú	_internalr   Úhttpr   r   r   r	   r
   r#   ÚcompileÚASCIIÚVERBOSEr<   rC   r0   rJ   r6   rK   r;   r!   r!   r!   r"   Ú<module>   s<    ÷O
ò


þ7