U aUA@sddlZddlZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ddlm Z ddl m Z ddlmZdd l mZdd l mZdd lmZdd lmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlmZddlm Z ej!r$ddl"Z#ddl$m%Z%e&dej'Z(e)dZ*e&dZ+ej&dej'dZ,e&dZ-e)ddddd d!d"d#d$d%g Z.e)d&d'd(d)d*d+d,d-gZ/d.d/d0d1d2d3d4d5d6d7d8d9d:d;dd?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdn@Z0Gdodpdpe Z1Gdqdrdre Z2dej3e4e5fe4e6e4dudvdwZ7de4e6e4dydzd{Z8ej9e4ej:e4ej9ej3e4e5ffe4d|d}d~Z;dej3ejde4dddZ?e4ej@e4dddZAeBfe4ejCeBej "[^"\\]*(?:\\.[^"\\]*)*" # quoted string | [^\s;,=*]+ # token ) (?:\*(?P\d+))? # *1, optional continuation index \s* (?: # optionally followed by =value (?: # equals sign, possibly with encoding \*\s*=\s* # * indicates extended notation (?: # optional encoding (?P[^\s]+?) '(?P[^\s]*?)' )? | =\s* # basic notation ) (?P "[^"\\]*(?:\\.[^"\\]*)*" # quoted string | [^;,]+ # token )? )? \s* )flagsz,\s*([^;,\s]+)([;,]\s*.+)?Zallowzcontent-encodingzcontent-languagezcontent-lengthcontent-locationz content-md5z content-rangez content-typeexpiresz last-modified connectionz keep-alivezproxy-authenticatezproxy-authorizationtetrailerztransfer-encodingupgradeContinuezSwitching Protocols Processingz Early HintsOKCreatedAcceptedzNon Authoritative Informationz No Contentz Reset ContentzPartial Contentz Multi StatuszAlready ReportedzIM UsedzMultiple ChoiceszMoved PermanentlyFoundz See Otherz Not Modifiedz Use Proxyz Switch ProxyzTemporary RedirectzPermanent Redirectz Bad Request UnauthorizedzPayment Required Forbiddenz Not FoundzMethod Not AllowedzNot AcceptablezProxy Authentication RequiredzRequest TimeoutConflictGonezLength RequiredzPrecondition FailedzRequest Entity Too LargezRequest URI Too LongzUnsupported Media TypezRequested Range Not SatisfiablezExpectation Failedz I'm a teapotzMisdirected RequestzUnprocessable EntityLockedzFailed Dependencyz Too EarlyzUpgrade RequiredzPrecondition RequiredzToo Many RequestszRequest Header Fields Too Largez Retry WithzUnavailable For Legal ReasonszInternal Server ErrorzNot Implementedz Bad GatewayzService UnavailablezGateway TimeoutzHTTP Version Not SupportedzVariant Also NegotiateszInsufficient Storagez Loop Detectedz Not ExtendedzNetwork Authentication Failed)@defgi,i-i.i/i0i1i2i3i4iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiic@seZdZdZdZdZdS)COEPzCross Origin Embedder Policies unsafe-nonez require-corpN)__name__ __module__ __qualname____doc__ UNSAFE_NONEZ REQUIRE_CORPr>r>NC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-1tps7o9u\werkzeug\http.pyr7sr7c@seZdZdZdZdZdZdS)COOPzCross Origin Opener Policiesr8zsame-origin-allow-popupsz same-originN)r9r:r;r<r=ZSAME_ORIGIN_ALLOW_POPUPSZ SAME_ORIGINr>r>r>r?r@sr@T)value extra_chars allow_tokenreturncCs^t|tr|d}t|}|r>tt|B}t||r>|S|dddd}d|dS)aQuote a header value if necessary. .. versionadded:: 0.5 :param value: the value to quote. :param extra_chars: a list of extra characters to skip quoting. :param allow_token: if this is enabled token values are returned unchanged. latin1\\\"\") isinstancebytesdecodestr _token_charssetissubsetreplace)rBrCrDZ token_charsr>r>r?quote_header_values   rSF)rB is_filenamerEcCs\|rX|d|dkr dkrXnn4|dd}|rD|dddkrX|ddd dS|S) a3Unquotes a header value. (Reversal of :func:`quote_header_value`). This does not use the real unquoting but what browsers are actually using for quoting. .. versionadded:: 0.5 :param value: the header value to unquote. :param is_filename: The value represents a filename or path. rrIrNrHrGrJ)rR)rBrTr>r>r?unquote_header_values $ rW)headeroptionsrEcCs^g}|dk r|||D]4\}}|dkr:||q||dt|qd|S)zThe reverse function to :func:`parse_options_header`. :param header: the header to dump :param options: a dict of options to append. N=; )appenditemsrSjoin)rXrYsegmentskeyrBr>r>r?dump_options_headers  ra)iterablerDrEc snt|trRg}|D]8\}}|dkr2||q||dt|dqnfdd|D}d|S)aJDump an HTTP header again. This is the reversal of :func:`parse_list_header`, :func:`parse_set_header` and :func:`parse_dict_header`. This also quotes strings that include an equals sign unless you pass it as dict of key, value pairs. >>> dump_header({'foo': 'bar baz'}) 'foo="bar baz"' >>> dump_header(('foo', 'bar baz')) 'foo, "bar baz"' :param iterable: the iterable or dict of values to quote. :param allow_token: if set to `False` tokens as values are disallowed. See :func:`quote_header_value` for more details. NrZrDcsg|]}t|dqS)rc)rS.0xrcr>r? $szdump_header..z, )rKdictr]r\rSr^)rbrDr]r`rBr>rcr? dump_headers  rizds.ContentSecurityPolicy)rXrEcCsddd|DS)zDump a Content Security Policy header. These are structured into policies such as "default-src 'self'; script-src 'self'". .. versionadded:: 1.0.0 Support for Content Security Policy headers was added. r[css |]\}}|d|VqdS) Nr>rer`rBr>r>r? 2sz"dump_csp_header..)r^r]rXr>r>r?dump_csp_header(s rn)rBrEcCsXg}t|D]F}|dd|ddkr4dkrHnnt|dd}||q |S)aParse 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` NrrUrI)_parse_list_headerrWr\)rBresultitemr>r>r?parse_list_header5s  ( rr)rBclsrEcCs|}t|tr|d}t|D]f}d|kr8d||<q"|dd\}}|dd|ddkrldkrnnt|dd}|||<q"|S)aKParse lists of key, value pairs as described by RFC 2068 Section 2 and convert them into a python dict (or any other mapping object created from the type with a dict like interface provided by the `cls` argument): >>> 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. .. versionchanged:: 0.9 Added support for `cls` argument. :param value: a string with a dict header. :param cls: callable to use for storage of parsed results. :return: an instance of `cls` rFrZNrrUrI)rKrLrMrosplitrW)rBrsrprqnamer>r>r?parse_dict_headerSs   ( rvzte.Literal[False])rBmultiplerEcCsdSNr>rBrwr>r>r?parse_options_header{srzzte.Literal[True].cCsdSrxr>ryr>r>r?rzsc Cs6|s difSg}d|dd}|r t|}|s8q ||di}|d}d}|rt|}|snq|\}} } } } | sd}n | s|} | }t|}| dk rt| |dk} | dk rt|  | } | r| |d| ||<n| ||<|| d}qZ|||dkrt |S|}q |r.t |SdifS) uParse a ``Content-Type`` like header into a tuple with the content type and the options: >>> parse_options_header('text/html; charset=utf8') ('text/html', {'charset': 'utf8'}) This should not be used to parse ``Cache-Control`` like headers that use a slightly different format. For these headers use the :func:`parse_dict_header` function. .. versionchanged:: 0.15 :rfc:`2231` parameter continuations are handled. .. versionadded:: 0.5 :param value: the header to parse. :param multiple: Whether try to parse and return multiple MIME types :return: (mimetype, options) or (mimetype, options, mimetype, options, …) if multiple=True rA, rrVNfilenameF) rR_option_header_start_mime_typematchr\group_option_header_piece_regroupsrW_unquoterMgetendtuple) rBrwrprrYrestZcontinued_encodingZoptmatchoptioncountencodinglanguageZ option_valuer>r>r?rzsH      _TAnyAcceptz ds.Accept)boundcCsdSrxr>)rBr>r>r?parse_accept_headersrcCsdSrxr>)rBrsr>r>r?rscCs|dkrttjttj}|s(|dSg}t|D]@}|d}|sNd}nt t t |dd}| |d|fq6||S)aParses an HTTP Accept-* header. This does not implement a complete valid algorithm but one that supports at least value and quality extraction. Returns a new :class:`Accept` object (basically a list of ``(value, quality)`` tuples sorted by the quality with some additional accessor methods). The second parameter can be a subclass of :class:`Accept` that is created with the parsed values and returned. :param value: the accept header string to be parsed. :param cls: the wrapper class for the return value (can be :class:`Accept` or a subclass thereof) :return: an instance of `cls`. NrVrr) tcastTyperdsAccept _accept_refinditerrmaxminfloatr\)rBrsrprZ quality_matchZqualityr>r>r?rs _TAnyCCzds._CacheControlzds.RequestCacheControl)rB on_updatersrEcCsdSrxr>rBrrsr>r>r?parse_cache_control_header srcCsdSrxr>rr>r>r?rscCs8|dkrttjttj}|s*|d|S|t||S)aParse a cache control header. The RFC differs between response and request cache control, this method does not. It's your responsibility to not use the wrong control statements. .. versionadded:: 0.5 The `cls` was added. If not specified an immutable :class:`~werkzeug.datastructures.RequestCacheControl` is returned. :param value: a cache control header to be parsed. :param on_update: an optional callable that is called every time a value on the :class:`~werkzeug.datastructures.CacheControl` object is changed. :param cls: the class for the returned object. By default :class:`~werkzeug.datastructures.RequestCacheControl` is used. :return: a `cls` object. Nr>)rrrrrZRequestCacheControlrvrr>r>r?rs  _TAnyCSPcCsdSrxr>rr>r>r?parse_csp_header:srcCsdSrxr>rr>r>r?rAscCs|dkrttjttj}|dkr.|d|Sg}|dD]>}|}d|kr<|dd\}}|||fq<|||S)aParse a Content Security Policy header. .. versionadded:: 1.0.0 Support for Content Security Policy headers was added. :param value: a csp header to be parsed. :param on_update: an optional callable that is called every time a value on the object is changed. :param cls: the class for the returned object. By default :class:`~werkzeug.datastructures.ContentSecurityPolicy` is used. :return: a `cls` object. Nr>;rjr) rrrrrZContentSecurityPolicyrtstripr\)rBrrsr]policy directiver>r>r?rHs z ds.HeaderSet)rBrrEcCs |std|Stt||S)aParse a set-like header and return a :class:`~werkzeug.datastructures.HeaderSet` object: >>> hs = parse_set_header('token, "quoted value"') The return value is an object that treats the items case-insensitively and keeps the order of the items: >>> 'TOKEN' in hs True >>> hs.index('quoted value') 1 >>> hs HeaderSet(['token', 'quoted value']) To create a header from the :class:`HeaderSet` again, use the :func:`dump_header` function. :param value: a set header to be parsed. :param on_update: an optional callable that is called every time a value on the :class:`~werkzeug.datastructures.HeaderSet` object is changed. :return: a :class:`~werkzeug.datastructures.HeaderSet` N)rZ HeaderSetrr)rBrr>r>r?parse_set_headerls rzds.AuthorizationcCs|sdSt|}z|dd\}}|}Wntk rBYdSX|dkrzt|dd\}}Wntk r|YdSXz tdt |dt |ddWSt k rYdSXn\|dkrt |}dD]}||krdSqd |kr| d r| d sdStd|SdS) awParse an HTTP basic/digest authorization header transmitted by the web browser. The return value is either `None` if the header was invalid or not given, otherwise an :class:`~werkzeug.datastructures.Authorization` object. :param value: the authorization header to parse. :return: a :class:`~werkzeug.datastructures.Authorization` object or `None`. Nrbasic:utf-8)usernamepassworddigest)rrealmnonceuriresponseqopZnccnonce) rrtlower ValueErrorbase64 b64decode Exceptionr AuthorizationrUnicodeDecodeErrorrvr)rB auth_type auth_inforrZauth_mapr`r>r>r?parse_authorization_headers@      rzds.WWWAuthenticatec Csn|stj|dSz|dd\}}|}Wn.ttfk rZtj||dYSXt|t||S)aParse an HTTP WWW-Authenticate header into a :class:`~werkzeug.datastructures.WWWAuthenticate` object. :param value: a WWW-Authenticate header to parse. :param on_update: an optional callable that is called every time a value on the :class:`~werkzeug.datastructures.WWWAuthenticate` object is changed. :return: a :class:`~werkzeug.datastructures.WWWAuthenticate` object. rNr)rZWWWAuthenticatertrrAttributeErrorrrv)rBrrrr>r>r?parse_www_authenticate_headers   rz ds.IfRangecCs:|s tSt|}|dk r(tj|dStt|dS)zParses an if-range header which can be an etag or a date. Returns a :class:`~werkzeug.datastructures.IfRange` object. .. versionchanged:: 2.0 If the value represents a datetime, it is timezone-aware. .. versionadded:: 0.7 Nrr)rZIfRange parse_date unquote_etag)rBrr>r>r?parse_if_range_headers  rzds.Range)rBmake_inclusiverEc Cs^|r d|krdSg}d}|dd\}}|}|dD]}|}d|krZdS|dr|dkrrdSz t|}Wntk rYdSXd}d}nd|krB|dd\} } | } | } | sdSt| }||ks|dkrdS| r,| sdSt| d}||kr0dSnd}|dk r>|nd}|||fq>t ||S)aParses a range header into a :class:`~werkzeug.datastructures.Range` object. If the header is missing or malformed `None` is returned. `ranges` is a list of ``(start, stop)`` tuples where the ranges are non-inclusive. .. versionadded:: 0.7 rZNrrr{-rU) rtrr startswithintrisdigitr\rZRange) rBrrangesZlast_endunitsrngrqbeginrZ begin_strZend_strr>r>r?parse_range_headersL         rzds.ContentRangec Cs|dkr dSz|pddd\}}Wntk r>YdSXd|krLdS|dd\}}|dkrjd}n|r|t|}ndS|dkrtj|dd||dSd|krdS|dd\}}zt|} t|d} Wntk rYdSXt| | |r tj|| | ||dSdS)aParses a range header into a :class:`~werkzeug.datastructures.ContentRange` object or `None` if parsing is not possible. .. versionadded:: 0.7 :param value: a content range header to be parsed. :param on_update: an optional callable that is called every time a value on the :class:`~werkzeug.datastructures.ContentRange` object is changed. NrAr/*rr)rrtrrrrZ ContentRangeis_byte_range_valid) rBrrZrangedefrZ length_strlengthZ start_strZstop_strstartstopr>r>r?parse_content_range_headers6 r)etagweakrEcCs.d|krtdd|d}|r*d|}|S)ziQuote an etag. :param etag: the etag to quote. :param weak: set to `True` to tag it "weak". rIz invalid etagW/)rrrr>r>r? quote_etagLs   rNN)rrEcCsj|sdS|}d}|dr.d}|dd}|dd|ddkrRd krbnn |dd}||fS) zUnquote a single etag: >>> unquote_etag('W/"bar"') ('bar', True) >>> unquote_etag('"bar"') ('bar', False) :param etag: the etag identifier to unquote. :return: a ``(etag, weak)`` tuple. rF)rzw/TrVNrrUrI)rrrr>r>r?rZs   ( rzds.ETagsc Cs|s tSg}g}t|}d}||krt||}|dkr>q|\}}}|dkr`tjddS|rh|}|rx||n |||}q t||S)zParse an etag header. :param value: the tag header to parse :return: an :class:`~werkzeug.datastructures.ETags` object. rNrT)Zstar_tag)rZETagslen_etag_rerrr\r) rBstrongrrposrZis_weakquotedrawr>r>r? parse_etagsss(     r)datarEcCs t|S)zGenerate an etag for some data. .. versionchanged:: 2.0 Use SHA-1. MD5 may not be available in some environments. )r hexdigest)rr>r>r? generate_etagsrc CsT|dkr dSztj|}Wnttfk r6YdSX|jdkrP|jtjdS|S)aKParse an :rfc:`2822` date into a timezone-aware :class:`datetime.datetime` object, or ``None`` if parsing fails. This is a wrapper for :func:`email.utils.parsedate_to_datetime`. It returns ``None`` if parsing fails instead of raising an exception, and always returns a timezone-aware datetime object. If the string doesn't have timezone information, it is assumed to be UTC. :param value: A string with a supported date format. .. versionchanged:: 2.0 Return a timezone-aware datetime object. Use ``email.utils.parsedate_to_datetime``. Ntzinfo) emailutilsparsedate_to_datetime TypeErrorrrrRrutc)rBdtr>r>r?rs r)rrEcCstjdtddt|S)zFormat a datetime object or timestamp into an :rfc:`2822` date string for ``Set-Cookie expires``. .. deprecated:: 2.0 Will be removed in Werkzeug 2.1. Use :func:`http_date` instead. zY'cookie_date' is deprecated and will be removed in Werkzeug 2.1. Use 'http_date' instead.rV stacklevel)warningswarnDeprecationWarning http_date)rr>r>r? cookie_dates r) timestamprEcCsdt|trBt|ts*tj|ttjd}nt|}tj j |ddSt|t rTt |}tj j |ddS)aFormat a datetime object or timestamp into an :rfc:`2822` date string. This is a wrapper for :func:`email.utils.format_datetime`. It assumes naive datetime objects are in UTC instead of raising an exception. :param timestamp: The datetime or timestamp to format. Defaults to the current time. .. versionchanged:: 2.0 Use ``email.utils.format_datetime``. Accept ``date`` objects. rT)usegmt)rKrrcombinerrrrrrformat_datetimer r formatdate)rr>r>r?rs   rcCs`|sdSz t|}Wntk r*YdSX|dkr8dSz t|dWStk rZYdSXdS)zParses a base-10 integer count of seconds into a timedelta. If parsing fails, the return value is `None`. :param value: a string consisting of an integer represented in base-10 :return: a :class:`datetime.timedelta` object or `None`. Nr)seconds)rrr OverflowError)rBrr>r>r? parse_ages  r)agerEcCsD|dkr dSt|tr$t|}nt|}|dkrr>r?dump_ages rr)environrr last_modifiedignore_if_rangerEc Cs8|dkr|dk rt|}n|dk r*tdd}t|tr@t|}|dk rXt|jdd}d}|svd|krvt|d}|dk r|j dk r|j }nt|d}|r|r||krd }|r2t |\}}t t|}|dk r|j dk rt|j |}n>t|d } | r| |}t|d } | r2| | }| S) a2Convenience method for conditional requests. :param environ: the WSGI environment of the request to be checked. :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`. .. versionchanged:: 2.0 SHA-1 is used to generate an etag value for the data. MD5 may not be available in some environments. .. versionchanged:: 1.0.0 The check is run for methods other than ``GET`` and ``HEAD``. Nzboth data and etag givenFr) microsecondZ HTTP_RANGEZ HTTP_IF_RANGEZHTTP_IF_MODIFIED_SINCETZHTTP_IF_NONE_MATCHZ HTTP_IF_MATCH)rrrKrNrrrRrrrrrrrrcontainsZ contains_weakZ is_strong) rrrrrZ unmodifiedZif_rangeZmodified_since_Z if_none_matchZif_matchr>r>r?is_resource_modifieds:       rrrz ds.Headers)headersallowedrEcs,ddDfdd|D|dd<dS)aRemove all entity headers from a list or :class:`Headers` object. This operation works in-place. `Expires` and `Content-Location` headers are by default not removed. The reason for this is :rfc:`2616` section 10.3.5 which specifies some entity headers that should be sent. .. versionchanged:: 0.5 added `allowed` parameter. :param headers: a list or :class:`Headers` object. :param allowed: a list of headers that should still be allowed even though they are entity headers. cSsh|] }|qSr>)rrdr>r>r? psz(remove_entity_headers..cs,g|]$\}}t|r |kr||fqSr>)is_entity_headerrrkrr>r?rgqs z)remove_entity_headers..Nr>)rrr>rr?remove_entity_headers`s r)rrEcCsdd|D|dd<dS)zRemove all HTTP/1.1 "Hop-by-Hop" headers from a list or :class:`Headers` object. This operation works in-place. .. versionadded:: 0.5 :param headers: a list or :class:`Headers` object. cSs g|]\}}t|s||fqSr>)is_hop_by_hop_headerrkr>r>r?rgsz-remove_hop_by_hop_headers..Nr>)rr>r>r?remove_hop_by_hop_headersxs r cCs |tkS)zCheck if a header is an entity header. .. versionadded:: 0.5 :param header: the header to test. :return: `True` if it's an entity header, `False` otherwise. )r_entity_headersrmr>r>r?rsrcCs |tkS)zCheck if a header is an HTTP/1.1 "Hop-by-Hop" header. .. versionadded:: 0.5 :param header: the header to test. :return: `True` if it's an HTTP/1.1 "Hop-by-Hop" header, `False` otherwise. )r_hop_by_hop_headersrmr>r>r?r sr rrRz ds.MultiDictzds.MultiDict[str, str])rXcharseterrorsrsrEcsxttrddn dkr$dttr:dd|dkrHtj}tjtj ttfdfdd }||S) a]Parse a cookie from a string or WSGI environ. 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 header: The cookie header as a string, or a WSGI environ dict with a ``HTTP_COOKIE`` key. :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`. .. versionchanged:: 1.0.0 Returns a :class:`MultiDict` instead of a ``TypeConversionDict``. .. versionchanged:: 0.5 Returns a :class:`TypeConversionDict` instead of a regular dict. The ``cls`` parameter was added. Z HTTP_COOKIErANrFrR)rEc3sFtD]8\}}t|dd}|s&qt|dd}||fVqdS)NT)Zallow_none_charset)rr)r`valZkey_strZval_strr rrXr>r? _parse_pairss z"parse_cookie.._parse_pairs) rKrhrrNencoderZ MultiDictrIteratorTuple)rXr rrsrr>rr? parse_cookies   & rr) r`rBmax_agerpathdomainsecurehttponlyr  sync_expiresmax_sizesamesiterEc  Cst||}t||}|dk r2ddlm} | ||}t|}t|trPt|}|dk rlt|tst |}n&|dk r| rt t j t j d|}| dk r| } | dkrtd|dt|g} d|d fd |d fd |d fd |dfd|dfd|d fd| d ffD]\}}}|dkr(|r| |q|dkr6qt|}t|ttfs\tt||}|rjt|}|d|7}| t|qd| }|d}t|}| r|| krt|}tjd||d|d||d|d| d dd|S)aCreate a Set-Cookie header without the ``Set-Cookie`` prefix. The return value is usually restricted to ascii as the vast majority of values are properly escaped, but that is no guarantee. It's tunneled through latin1 as required by :pep:`3333`. The return value is not ASCII safe if the key contains unicode characters. This is technically against the specification but happens in the wild. It's strongly recommended to not use non-ASCII values for the keys. :param max_age: should be a number of seconds, or `None` (default) if the cookie should last only as long as the client's browser session. Additionally `timedelta` objects are accepted, too. :param expires: should be a `datetime` object or unix timestamp. :param path: limits the cookie to a given path, per default it will span the whole domain. :param domain: Use this if you want to set a cross-domain cookie. For example, ``domain=".example.com"`` will set a cookie that is readable by the domain ``www.example.com``, ``foo.example.com`` etc. Otherwise, a cookie will only be readable by the domain that set it. :param secure: The cookie will only be available via HTTPS :param httponly: disallow JavaScript to access the cookie. This is an extension to the cookie standard and probably not supported by all browsers. :param charset: the encoding for string values. :param sync_expires: automatically set expires if max_age is defined but expires not. :param max_size: Warn if the final header value exceeds this size. The default, 4093, should be safely `supported by most browsers `_. Set to 0 to disable this check. :param samesite: Limits the scope of the cookie such that it will only be attached to requests if those requests are same-site. .. _`cookie`: http://browsercookielimits.squawky.net/ .. versionchanged:: 1.0.0 The string ``'None'`` is accepted for ``samesite``. Nr) iri_to_uri)tz>StrictLaxNonez,SameSite must be 'Strict', 'Lax', or 'None'.=sDomainTsExpiresFsMax-AgesSecuresHttpOnlysPathsSameSites; rFzThe z$ cookie is too large: the value was z bytes but the header required z! extra bytes. The final size was z bytes but the limit is z> bytes. Browsers may silently ignore cookies larger than this.rVr)rurlsrrrKrrrrNrrnowrrrtitlerrr\ bytearrayrLr^rMrrr)r`rBrrrrrrr rrrrbufkvqtmprvZ cookie_sizeZ value_sizer>r>r? dump_cookiesb7               , r/)rrrrEcCsp|dk|dkkrdS|dkr,|dkp*|dkS|dkrLd|koF|kSS||krXdSd|koj|kSS)zcChecks if a given byte content range is valid for the given length. .. versionadded:: 0.7 NFrr>)rrrr>r>r?rYsr)datastructures)rAT)F)T)F)F)N)N)NN)N)NN)N)N)T)N)F)N)N)N)N)NNNT)r)rrRN) rANNrNFFrTrN)or email.utilsrretypingrrrrrrrenumrhashlibr r r urllib.parser rurllib.requestr ro _internalrrrrrrZwerkzeug._internalr TYPE_CHECKINGZtyping_extensionsrZ_typeshed.wsgircompileVERBOSEr frozensetrOrrr~r r ZHTTP_STATUS_CODESr7r@UnionrNrboolrSrWOptionalMappingraDictIterablerirnListrrrhrrvoverloadrrzAnyTypeVarrrrCallableZ _t_cc_updaterrZ _t_csp_updaterrrrrrrrrrrLrrrrrrrrrr rr rr/rrAr0rr>r>r>r?s                      D    &  &(, K #  & " 0  8 2    * P     8