U
    ÌZj*  ã                   @   s"  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
lmZ ddlmZ e  d¡Zdeje eje eje eje eje eje eje ejejeef  eedœ
dd„Zdejeedf eeejejd  ddœdd„ZddlmZ dS )é    N)Údatetimeé   )Ú_cookie_parse_impl)Ú
_dt_as_utc)Ú_to_str)Úgenerate_etag)Ú
parse_date)Úparse_etags)Úparse_if_range_header)Úunquote_etagz&([Ww]/)?(?:"(.*?)"|(.*?))(?:\s*,\s*|$)T)
Ú
http_rangeÚhttp_if_rangeÚhttp_if_modified_sinceÚhttp_if_none_matchÚhttp_if_matchÚetagÚdataÚlast_modifiedÚignore_if_rangeÚreturnc	                 C   s  |dkr|dk	rt |ƒ}n|dk	r*tdƒ‚d}	t|tƒr@t|ƒ}|dk	rXt|jdd�ƒ}d}
|sp| dk	rpt|ƒ}
|
dk	rŠ|
jdk	rŠ|
j}nt|ƒ}|r¦|r¦||kr¦d}	|�rt	|ƒ\}}t
 t|¡}|
dk	rè|
jdk	rèt|
jƒ |¡}	n0t|ƒ}|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    úW/var/www/html/TRUCKING_PROJECT/venv/lib/python3.8/site-packages/werkzeug/sansio/http.pyÚis_resource_modified   s:    


r"   Ú úutf-8r   zds.MultiDictzds.MultiDict[str, str])ÚcookieÚcharsetÚerrorsÚclsr   c                    sT   t ˆtƒrˆ dd¡‰|dkr$tj}tjtjttf  dœ‡ ‡‡fdd„}||ƒ ƒ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 charset: The charset for the cookie values.
    :param errors: The error behavior for the charset decoding.
    :param cls: A dict-like class to store the parsed cookies in.
        Defaults to :class:`MultiDict`.

    .. versionadded:: 2.2
    Úlatin1r   N)r   c                  3   sF   t ˆƒD ]8\} }t| ˆ ˆdd�}|s&qt|ˆ ˆdd�}||fV  qd S )NT)Zallow_none_charset)r   r   )ÚkeyÚvalZkey_strZval_str©r&   r%   r'   r    r!   Ú_parse_pairs~   s    z"parse_cookie.<locals>._parse_pairs)r   r   ÚencodeÚdsZ	MultiDictr   ÚIteratorÚTuple)r%   r&   r'   r(   r-   r    r,   r!   Úparse_cookiea   s    
&
r2   )Údatastructures)	NNNNNNNNT)r#   r$   r   N)ÚreÚtypingr   r   Ú	_internalr   r   r   Úhttpr   r   r	   r
   r   ÚcompileZ_etag_reÚOptionalr   ÚbytesÚUnionÚboolr"   ÚTyper2   r#   r3   r/   r    r    r    r!   Ú<module>   sX   
         ÷öQ    üû+