403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/werkzeug/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/werkzeug/__pycache__/datastructures.cpython-311.pyc
�

��b;{���ddlZddlZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZdd	lmZdd
lmZd�Zd�ZGd
�d��ZGd�dee��ZGd�d��ZGd�de��Zd�ZGd�de��ZGd�de��ZGd�dee��ZGd�de��ZGd�d��Z Gd �d!e��Z!d"�Z"d#�Z#Gd$�d%��Z$Gd&�d'��Z%Gd(�d)e%e$��Z&Gd*�d+ee��Z'Gd,�d-e��Z(Gd.�d/ee��Z)Gd0�d1ee��Z*Gd2�d3ee!��Z+Gd4�d5e��Z,ej-d6��Z.d7�Z/Gd8�d9e,��Z0ej-d:��Z1d;�Z2Gd<�d=e,��Z3Gd>�d?e,��Z4d@�Z5GdA�dBee��Z6GdC�dDee6��Z7GdE�dFe6��Z8dG�Z9GdH�dIee��Z:GdJ�dKee��Z;GdL�dMe��Z<GdN�dOe��Z=GdP�dQ��Z>GdR�dS��Z?dT�Z@GdU�dV��ZAGdW�dXee��ZBd`dY�ZCd`dZ�ZDGd[�d\ee��ZEGd]�d^��ZFdd_lmGZGdS)a�N)�
Collection)�
MutableSet��deepcopy)�BytesIO)�repeat)�fspath�)�
exceptions)�_missingc�J�tt|��j�d����)Nz objects are immutable��	TypeError�type�__name__��selfs �9/usr/lib/python3/dist-packages/werkzeug/datastructures.py�is_immutablers"��
�t�D�z�z�*�D�D�D�
E�
E�E�c#�>K�t|t��r|�d���Ed{V��dSt|t��rJ|���D]3\}}t|tt
f��r|D]}||fV��	�-||fV��4dS|Ed{V��dS)zyIterates over the items of a mapping yielding keys and values
    without dropping any from more complex structures.
    T��multiN)�
isinstance�	MultiDict�items�dict�tuple�list)�mapping�key�value�vs    r�iter_multi_itemsr$s������'�9�%�%�
��=�=�t�=�,�,�,�,�,�,�,�,�,�,�,�	�G�T�	"�	"��!�-�-�/�/�	!�	!�J�C���%�%���/�/�
!��!�!�A��q�&�L�L�L�L�!��5�j� � � � �	!�	!����������rc�h�eZdZdZdZd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zdd�Zd�Zdd�ZdS)�ImmutableListMixinzOMakes a :class:`list` immutable.

    .. versionadded:: 0.5

    :private:
    Nc�h�|j�|jStt|����x}|_|S�N)�_hash_cache�hashr�r�rvs  r�__hash__zImmutableListMixin.__hash__0s4����'��#�#� $�U�4�[�[� 1� 1�1��T�
��	rc�@�t|��t|��ffSr()rr�r�protocols  r�
__reduce_ex__z ImmutableListMixin.__reduce_ex__6����D�z�z�D��J�J�=�(�(rc�$�t|��dSr(�r�rr!s  r�__delitem__zImmutableListMixin.__delitem__9����T�����rc�$�t|��dSr(r4�r�others  r�__iadd__zImmutableListMixin.__iadd__<r7rc�$�t|��dSr(r4r9s  r�__imul__zImmutableListMixin.__imul__?r7rc�$�t|��dSr(r4�rr!r"s   r�__setitem__zImmutableListMixin.__setitem__Br7rc�$�t|��dSr(r4�r�items  r�appendzImmutableListMixin.appendEr7rc�$�t|��dSr(r4rBs  r�removezImmutableListMixin.removeHr7rc�$�t|��dSr(r4)r�iterables  r�extendzImmutableListMixin.extendKr7rc�$�t|��dSr(r4�r�posr"s   r�insertzImmutableListMixin.insertNr7r���c�$�t|��dSr(r4)r�indexs  r�popzImmutableListMixin.popQr7rc�$�t|��dSr(r4rs r�reversezImmutableListMixin.reverseTr7rFc�$�t|��dSr(r4)rr!rSs   r�sortzImmutableListMixin.sortWr7r�rN�NF)r�
__module__�__qualname__�__doc__r)r-r1r6r;r=r@rDrFrIrMrQrSrU�rrr&r&&s����������K����)�)�)�������������������������������������rr&c��eZdZdZd�ZdS)�
ImmutableListzJAn immutable :class:`list`.

    .. versionadded:: 0.5

    :private:
    c�f�t|��j�dt�|���d�S�N�(�))rrr�__repr__rs rrbzImmutableList.__repr__c�.���t�*�*�%�>�>��
�
�d�(;�(;�>�>�>�>rN)rrXrYrZrbr[rrr]r][s-��������?�?�?�?�?rr]c�x��eZdZdZdZed�fd�	��Zd�Zd�Zd�Z	dd�Z
d�Zdd	�Zd
�Z
d�Zd�Zd
�Z�xZS)�ImmutableDictMixinzOMakes a :class:`dict` immutable.

    .. versionadded:: 0.5

    :private:
    Nc���t���|��}|�t|t	|������|Sr()�super�__new__�__init__�zipr)�cls�keysr"�instance�	__class__s    �r�fromkeyszImmutableDictMixin.fromkeysqsA����7�7�?�?�3�'�'�����#�d�F�5�M�M�2�2�3�3�3��rc�@�t|��t|��ffSr()rrr/s  rr1z ImmutableDictMixin.__reduce_ex__wr2rc�*�|���Sr(�rrs r�_iter_hashitemsz"ImmutableDictMixin._iter_hashitemszs���z�z�|�|�rc��|j�|jStt|�������x}|_|Sr()r)r*�	frozensetrsr+s  rr-zImmutableDictMixin.__hash__}sB����'��#�#� $�Y�t�/C�/C�/E�/E�%F�%F� G� G�G��T�
��	rc�$�t|��dSr(r4�rr!�defaults   r�
setdefaultzImmutableDictMixin.setdefault�r7rc�$�t|��dSr(r4�r�args�kwargss   r�updatezImmutableDictMixin.update�r7rc�$�t|��dSr(r4rws   rrQzImmutableDictMixin.pop�r7rc�$�t|��dSr(r4rs r�popitemzImmutableDictMixin.popitem�r7rc�$�t|��dSr(r4r?s   rr@zImmutableDictMixin.__setitem__�r7rc�$�t|��dSr(r4r5s  rr6zImmutableDictMixin.__delitem__�r7rc�$�t|��dSr(r4rs r�clearzImmutableDictMixin.clear�r7rr()rrXrYrZr)�classmethodror1rsr-ryr~rQr�r@r6r��
__classcell__�rns@rreregs�����������K��������[��
)�)�)���������������������������������rrec�>�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d
d	�Z
dS)�ImmutableMultiDictMixinzTMakes a :class:`MultiDict` immutable.

    .. versionadded:: 0.5

    :private:
    c�h�t|��t|�d�����ffS�NTr�rrrr/s  rr1z%ImmutableMultiDictMixin.__reduce_ex__��,���D�z�z�D����$��!7�!7�8�8�:�:�:rc�.�|�d���Sr�rrrs rrsz'ImmutableMultiDictMixin._iter_hashitems�s���z�z��z�%�%�%rc�$�t|��dSr(r4r?s   r�addzImmutableMultiDictMixin.add�r7rc�$�t|��dSr(r4rs r�popitemlistz#ImmutableMultiDictMixin.popitemlist�r7rc�$�t|��dSr(r4r5s  r�poplistzImmutableMultiDictMixin.poplist�r7rc�$�t|��dSr(r4�rr!�new_lists   r�setlistzImmutableMultiDictMixin.setlist�r7rNc�$�t|��dSr(r4�rr!�default_lists   r�setlistdefaultz&ImmutableMultiDictMixin.setlistdefault�r7rr()rrXrYrZr1rsr�r�r�r�r�r[rrr�r��s���������;�;�;�&�&�&������������������rr�c� ���fd�}�|_|S)Nc���ttt|�����|i|��}|j�|�|��|Sr()�getattrrg�UpdateDictMixin�	on_update)rr|�kwr,�names    �r�oncallz_calls_update.<locals>.oncall�sJ���
8�W�U�?�D�1�1�4�
8�
8�$�
E�"�
E�
E���>�%��N�N�4� � � ��	r)r)r�r�s` r�
_calls_updater��s*���������F�O��Mrc���eZdZdZdZd
�fd�	Zef�fd�	Zed��Z	ed��Z
ed��Zed��Zed	��Z
�xZS)r�zbMakes dicts call `self.on_update` on modifications.

    .. versionadded:: 0.5

    :private:
    Nc���||v}t���||��}|r|j�|�|��|Sr()rgryr��rr!rx�modifiedr,rns     �rryzUpdateDictMixin.setdefault�sK����d�?��
�W�W�
�
��W�
-�
-���	!���2��N�N�4� � � ��	rc����||v}|tur"t���|��}n"t���||��}|r|j�|�|��|Sr()rrgrQr�r�s     �rrQzUpdateDictMixin.pop�sk����$�;���h��������S�!�!�B�B������S�'�*�*�B��	!���2��N�N�4� � � ��	rr@r6r�r�r~r()rrXrYrZr�ryrrQr�r@r6r�r�r~r�r�s@rr�r��s�����������I������� (������� �-�
�.�.�K��-�
�.�.�K��M�'�"�"�E��m�I�&�&�G�
�]�8�
$�
$�F�F�F�F�Frr�c��eZdZdZdd�ZdS)�TypeConversionDictz�Works like a regular dict but the :meth:`get` method can perform
    type conversions.  :class:`MultiDict` and :class:`CombinedMultiDict`
    are subclasses of this class and provide the same feature.

    .. versionadded:: 0.5
    Nc��	||}n#t$r|cYSwxYw|�	||��}n#t$r|}YnwxYw|S)a�Return the default value if the requested data doesn't exist.
        If `type` is provided and is a callable it should convert the value,
        return it or raise a :exc:`ValueError` if that is not possible.  In
        this case the function will return the default as if the value was not
        found:

        >>> d = TypeConversionDict(foo='42', bar='blub')
        >>> d.get('foo', type=int)
        42
        >>> d.get('bar', -1, type=int)
        -1

        :param key: The key to be looked up.
        :param default: The default value to be returned if the key can't
                        be looked up.  If not further specified `None` is
                        returned.
        :param type: A callable that is used to cast the value in the
                     :class:`MultiDict`.  If a :exc:`ValueError` is raised
                     by this callable the default value is returned.
        )�KeyError�
ValueError)rr!rxrr,s     r�getzTypeConversionDict.get�sy��*	��c��B�B���	�	�	��N�N�N�	������
��T�"�X�X�����
�
�
�����
�����	s����,�;�;�NN)rrXrYrZr�r[rrr�r��s2�������������rr�c��eZdZdZd�Zd�ZdS)�ImmutableTypeConversionDictzpWorks like a :class:`TypeConversionDict` but does not support
    modifications.

    .. versionadded:: 0.5
    c� �t|��S�z�Return a shallow mutable copy of this object.  Keep in mind that
        the standard library's :func:`copy` function is a no-op for this class
        like for any other python immutable type (eg: :class:`tuple`).
        )r�rs r�copyz ImmutableTypeConversionDict.copys��
"�$�'�'�'rc��|Sr(r[rs r�__copy__z$ImmutableTypeConversionDict.__copy__����rN�rrXrYrZr�r�r[rrr�r�s<��������(�(�(�����rr�c��eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
dd
�Zd�Zdd�Z
dd
�Zd d�Zd�Zd�Zd�Zd�Zdd�Zd!d�Zd�Zefd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS)"raA :class:`MultiDict` is a dictionary subclass customized to deal with
    multiple values for the same key which is for example used by the parsing
    functions in the wrappers.  This is necessary because some HTML form
    elements pass multiple values for the same key.

    :class:`MultiDict` implements all standard dictionary methods.
    Internally, it saves all values for a key as a list, but the standard dict
    access methods will only return the first value for a key. If you want to
    gain access to the other values, too, you have to use the `list` methods as
    explained below.

    Basic Usage:

    >>> d = MultiDict([('a', 'b'), ('a', 'c')])
    >>> d
    MultiDict([('a', 'b'), ('a', 'c')])
    >>> d['a']
    'b'
    >>> d.getlist('a')
    ['b', 'c']
    >>> 'a' in d
    True

    It behaves like a normal dict thus all dict functions will only return the
    first value when multiple values for one key are found.

    From Werkzeug 0.3 onwards, the `KeyError` raised by this class is also a
    subclass of the :exc:`~exceptions.BadRequest` HTTP exception and will
    render a page for a ``400 BAD REQUEST`` if caught in a catch-all for HTTP
    exceptions.

    A :class:`MultiDict` can be constructed from an iterable of
    ``(key, value)`` tuples, a dict, a :class:`MultiDict` or from Werkzeug 0.2
    onwards some keyword parameters.

    :param mapping: the initial value for the :class:`MultiDict`.  Either a
                    regular dict, an iterable of ``(key, value)`` tuples
                    or `None`.
    Nc�n�t|t��r9t�|d�|���D����dSt|t��r�i}|���D]M\}}t|ttf��r$t|��dkr�5t|��}n|g}|||<�Nt�||��dSi}|pdD].\}}|�	|g���
|���/t�||��dS)Nc3�4K�|]\}}||dd�fV��dSr(r[)�.0�k�ls   r�	<genexpr>z%MultiDict.__init__.<locals>.<genexpr>Ls2���� G� G�t�q�!�!�Q�q�q�q�T�� G� G� G� G� G� Grrr[)rrrri�listsrrr�lenryrD)rr �tmpr!r"s     rrizMultiDict.__init__Js3���g�y�)�)�	%��M�M�$� G� G�w�}�}��� G� G� G�H�H�H�H�H�
���
&�
&�	%��C�%�m�m�o�o�
!�
!�
��U��e�e�T�]�3�3�$��5�z�z�Q��� � ��K�K�E�E�"�G�E� ��C����M�M�$��$�$�$�$�$��C�%�m��
6�
6�
��U����s�B�'�'�.�.�u�5�5�5�5��M�M�$��$�$�$�$�$rc�D�t|�����Sr()rr�rs r�__getstate__zMultiDict.__getstate__^s���D�J�J�L�L�!�!�!rc�p�t�|��t�||��dSr()rr�r~�rr"s  r�__setstate__zMultiDict.__setstate__as.���
�
�4�������D�%� � � � � rc�6�t�|��Sr()r�__iter__rs rr�zMultiDict.__iter__es���}�}�T�"�"�"rc��||vr6t�||��}t|��dkr|dStj|���)z�Return the first data value for this key;
        raises KeyError if not found.

        :param key: The key to be looked up.
        :raise KeyError: if the key does not exist.
        r)r�__getitem__r�r�BadRequestKeyError)rr!�lsts   rr�zMultiDict.__getitem__ksK���$�;�;��"�"�4��-�-�C��3�x�x�!�|�|��1�v�
��+�C�0�0�0rc�@�t�|||g��dS)z�Like :meth:`add` but removes an existing key first.

        :param key: the key for the value.
        :param value: the value to set.
        N)rr@r?s   rr@zMultiDict.__setitem__ys$��	
����s�U�G�,�,�,�,�,rc�d�t�||g���|��dS)z�Adds a new value for the key.

        .. versionadded:: 0.6

        :param key: the key for the value.
        :param value: the value to add.
        N)rryrDr?s   rr�z
MultiDict.add�s.��	
����c�2�&�&�-�-�e�4�4�4�4�4rc���	t�||��}n#t$rgcYSwxYw|�t|��Sg}|D]1}	|�||�����"#t
$rY�.wxYw|S)a]Return the list of items for a given key. If that key is not in the
        `MultiDict`, the return value will be an empty list.  Just like `get`,
        `getlist` accepts a `type` parameter.  All items will be converted
        with the callable defined there.

        :param key: The key to be looked up.
        :param type: A callable that is used to cast the value in the
                     :class:`MultiDict`.  If a :exc:`ValueError` is raised
                     by this callable the value will be removed from the list.
        :return: a :class:`list` of all the values for the key.
        )rr�r�rrDr��rr!rr,�resultrCs      r�getlistzMultiDict.getlist�s���	��!�!�$��,�,�B�B���	�	�	��I�I�I�	�����<���8�8�O����	�	�D�
��
�
�d�d�4�j�j�)�)�)�)���
�
�
���
�����
s��-�-�A'�'
A4�3A4c�X�t�||t|����dS)aRemove the old values for a key and add new ones.  Note that the list
        you pass the values in will be shallow-copied before it is inserted in
        the dictionary.

        >>> d = MultiDict()
        >>> d.setlist('foo', ['1', '2'])
        >>> d['foo']
        '1'
        >>> d.getlist('foo')
        ['1', '2']

        :param key: The key for which the values are set.
        :param new_list: An iterable with the new values for the key.  Old values
                         are removed first.
        N)rr@rr�s   rr�zMultiDict.setlist�s(�� 	
����s�D��N�N�3�3�3�3�3rc�*�||vr|||<n||}|S)aGReturns the value for the key if it is in the dict, otherwise it
        returns `default` and sets that value for `key`.

        :param key: The key to be looked up.
        :param default: The default value to be returned if the key is not
                        in the dict.  If not further specified it's `None`.
        r[rws   rryzMultiDict.setdefault�s&���d�?�?��D��I�I��3�i�G��rc��||vr.t|pd��}t�|||��nt�||��}|S)a�Like `setdefault` but sets multiple values.  The list returned
        is not a copy, but the list that is actually used internally.  This
        means that you can put new values into the dict by appending items
        to the list:

        >>> d = MultiDict({"foo": 1})
        >>> d.setlistdefault("foo").extend([2, 3])
        >>> d.getlist("foo")
        [1, 2, 3]

        :param key: The key to be looked up.
        :param default_list: An iterable of default values.  It is either copied
                             (in case it was a list) or converted into a list
                             before returned.
        :return: a :class:`list`
        r[)rrr@r�r�s   rr�zMultiDict.setlistdefault�sU��"�d�?�?��� 2��3�3�L����T�3��5�5�5�5��+�+�D�#�6�6�L��rFc#�~K�t�|��D]\}}|r|D]}||fV��	�||dfV�� dS)aReturn an iterator of ``(key, value)`` pairs.

        :param multi: If set to `True` the iterator returned will have a pair
                      for each value of each key.  Otherwise it will only
                      contain pairs for the first value of each key.
        rN)rr)rrr!�valuesr"s     rrzMultiDict.items�sy���� �:�:�d�+�+�	%�	%�K�C���
%�#�%�%�E��u�*�$�$�$�$�%��6�!�9�n�$�$�$�$�	%�	%rc#�pK�t�|��D]\}}|t|��fV��dS)zuReturn a iterator of ``(key, values)`` pairs, where values is the list
        of all values associated with the key.N)rrr�rr!r�s   rr�zMultiDict.lists�sK���� �:�:�d�+�+�	$�	$�K�C���t�F�|�|�#�#�#�#�#�	$�	$rc#�XK�t�|��D]}|dV��
dS)zAReturns an iterator of the first value on every key's value list.rN�rr��rr�s  rr�zMultiDict.values�s:�����k�k�$�'�'�	�	�F���)�O�O�O�O�	�	rc�6�t�|��S)aReturn an iterator of all values associated with a key.  Zipping
        :meth:`keys` and this is the same as calling :meth:`lists`:

        >>> d = MultiDict({"foo": [1, 2, 3]})
        >>> zip(d.keys(), d.listvalues()) == d.lists()
        True
        r�rs r�
listvalueszMultiDict.listvalues�s���{�{�4� � � rc�,�|�|��S)z%Return a shallow copy of this object.r�rs rr�zMultiDict.copys���~�~�d�#�#�#rc�p�|�t|�d���|����S)z"Return a deep copy of this object.F)�flat)rnr�to_dict�r�memos  rrzMultiDict.deepcopys,���~�~�h�t�|�|��|�'?�'?��F�F�G�G�GrTc��|r!t|�����St|�����S)a�Return the contents as regular dict.  If `flat` is `True` the
        returned dict will only have the first item present, if `flat` is
        `False` all values will be returned as lists.

        :param flat: If set to `False` the dict returned will have lists
                     with all the values in it.  Otherwise it will only
                     contain the first value for each key.
        :return: a :class:`dict`
        �rrr��rr�s  rr�zMultiDict.to_dicts8���	&���
�
���%�%�%��D�J�J�L�L�!�!�!rc�h�t|��D]!\}}t�|||���"dS)a�update() extends rather than replaces existing key lists:

        >>> a = MultiDict({'x': 1})
        >>> b = MultiDict({'x': 2, 'y': 3})
        >>> a.update(b)
        >>> a
        MultiDict([('y', 3), ('x', 1), ('x', 2)])

        If the value list for a key in ``other_dict`` is empty, no new values
        will be added to the dict and the key will not be created:

        >>> x = {'empty_list': []}
        >>> y = MultiDict()
        >>> y.update(x)
        >>> y
        MultiDict([])
        N)r$rr��rr r!r"s    rr~zMultiDict.updatesB��$+�7�3�3�	,�	,�J�C���M�M�$��U�+�+�+�+�	,�	,rc��	t�||��}t|��dkrtj|���|dS#t
$r#|tur|cYStj|��d�wxYw)a�Pop the first item for a list on the dict.  Afterwards the
        key is removed from the dict, so additional values are discarded:

        >>> d = MultiDict({"foo": [1, 2, 3]})
        >>> d.pop("foo")
        1
        >>> "foo" in d
        False

        :param key: the key to pop.
        :param default: if provided the value to return if the key was
                        not in the dictionary.
        rN)rrQr�rr�r�r)rr!rxr�s    rrQz
MultiDict.pop+s���	?��(�(�4��%�%�C��3�x�x�1�}�}� �3�C�8�8�8��q�6�M���	?�	?�	?��h�&�&������/��4�4�$�>�		?���s�A	A�A9�#A9c�.�	t�|��}t|d��dkrtj|d���|d|ddfS#t
$r%}tj|jd��d�d}~wwxYw)zPop an item from the dict.r
rN)rr�r�rr�r�r|)rrC�es   rr�zMultiDict.popitemFs���	E��<�<��%�%�D��4��7�|�|�q� � � �3�D��G�<�<�<���G�T�!�W�Q�Z�(�(���	E�	E�	E��/���q�	�:�:��D�����	E���s�A"A%�%
B�/ B�Bc�:�t�||g��S)z�Pop the list for a key from the dict.  If the key is not in the dict
        an empty list is returned.

        .. versionchanged:: 0.5
           If the key does no longer exist a list is returned instead of
           raising an error.
        )rrQr5s  rr�zMultiDict.poplistRs���x�x��c�2�&�&�&rc��	t�|��S#t$r%}tj|jd��d�d}~wwxYw)z*Pop a ``(key, list)`` tuple from the dict.rN)rr�r�rr�r|)rr�s  rr�zMultiDict.popitemlist\sV��	E��<�<��%�%�%���	E�	E�	E��/���q�	�:�:��D�����	E���s��
A� A�Ac�*�|���Sr(�r�rs rr�zMultiDict.__copy__c����y�y�{�{�rc�.�|�|���S)N)r�rr�s  r�__deepcopy__zMultiDict.__deepcopy__fs���}�}�$�}�'�'�'rc�x�t|��j�dt|�d������d�S)Nr`Trra)rrrrrs rrbzMultiDict.__repr__is8���t�*�*�%�I�I��T�Z�Z�d�Z�-C�-C�(D�(D�I�I�I�Irr(�F�T)rrXrYrZrir�r�r�r�r@r�r�r�ryr�rr�r�r�r�rr�r~rrQr�r�r�r�r�rbr[rrrr!s�������&�&�P%�%�%�%�("�"�"�!�!�!�#�#�#�1�1�1�-�-�-�5�5�5�����44�4�4�$��������0%�%�%�%�$�$�$����
!�!�!�$�$�$�H�H�H�H�"�"�"�"�,�,�,�* (�?�?�?�?�6
E�
E�
E�'�'�'�E�E�E����(�(�(�J�J�J�J�Jrrc�"�eZdZdZdZd�Zd�ZdS)�_omd_bucketaWraps values in the :class:`OrderedMultiDict`.  This makes it
    possible to keep an order over multiple different keys.  It requires
    a lot of extra memory and slows down access a lot, but makes it
    possible to access elements in O(1) and iterate in O(n).
    )�prevr!r"�nextc��|j|_||_||_d|_|j�||_|j�||j_||_dSr()�_last_bucketr�r!r"r��
_first_bucket)r�omdr!r"s    rriz_omd_bucket.__init__vsT���$��	������
���	���$� $�C����'�$(�C��!�����rc��|jr|j|j_|jr|j|j_|j|ur|j|_|j|ur|j|_dSdSr()r�r�rr)rrs  r�unlinkz_omd_bucket.unlink�sj���9�	'�!�Y�D�I�N��9�	'�!�Y�D�I�N����$�$� $�	�C����t�#�#�#�y�C����$�#rN)rrXrYrZ�	__slots__rirr[rrr�r�msC��������1�I�
 �
 �
 �)�)�)�)�)rr�c��eZdZdZdd�Zd�ZdZd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zdd�Zd�Zd�Zd�Zdd�Zd�Zdd�Zd�Zd�Zefd�Zd�Zd�ZdS)�OrderedMultiDictaNWorks like a regular :class:`MultiDict` but preserves the
    order of the fields.  To convert the ordered multi dict into a
    list you can use the :meth:`items` method and pass it ``multi=True``.

    In general an :class:`OrderedMultiDict` is an order of magnitude
    slower than a :class:`MultiDict`.

    .. admonition:: note

       Due to a limitation in Python you cannot convert an ordered
       multi dict into a regular dict by using ``dict(multidict)``.
       Instead you have to use the :meth:`to_dict` method, otherwise
       the internal bucket objects are exposed.
    Nc��t�|��dx|_|_|�t�||��dSdSr()rrirrrr~)rr s  rrizOrderedMultiDict.__init__�sN���
�
�d����15�5���T�.����#�#�D�'�2�2�2�2�2��rc�d�t|t��stSt|t��r�t	|�d�����}t	|�d�����}	|D]&\}}t
|��\}}||ks||krdS�'n#t$rYdSwxYw	t
|��n#t$rYdSwxYwdSt|��t|��krdS|�	��D]!\}}	|�
|��|	krdS�"dS)NTrF)rr�NotImplementedr�iterrr��
StopIterationr�r�r�)
rr:�iter1�iter2�k1�v1�k2�v2r!r�s
          r�__eq__zOrderedMultiDict.__eq__�sh���%��+�+�	"�!�!��e�-�.�.�	�����$��/�/�0�0�E�����4��0�0�1�1�E�
�#�%�%�F�B��!�%�[�[�F�B���R�x�x�2��8�8�$�u�u�$,�%��!�
�
�
��u�u�
����
��U������ �
�
�
��t�t�
�����5��t�9�9��E�
�
�"�"��5��:�:�<�<�	�	�K�C���}�}�S�!�!�V�+�+��u�u�,��ts*�9&B#�!B#�#
B1�0B1�5C�
C�Cc�h�t|��t|�d�����ffSr�r�r/s  rr1zOrderedMultiDict.__reduce_ex__�r�rc�H�t|�d�����Sr�)rrrs rr�zOrderedMultiDict.__getstate__�s���D�J�J�T�J�*�*�+�+�+rc�v�t�|��|D]\}}|�||���dSr()rr�r�)rr�r!r"s    rr�zOrderedMultiDict.__setstate__�sH���
�
�4���� �	!�	!�J�C���H�H�S�%� � � � �	!�	!rc�~�||vr&t�||��djStj|����Nr)rr�r"rr�r5s  rr�zOrderedMultiDict.__getitem__�s:���$�;�;��#�#�D�#�.�.�q�1�7�7��+�C�0�0�0rc�\�|�|��|�||��dSr(�r�r�r?s   rr@zOrderedMultiDict.__setitem__�s.�����S��������e�����rc�0�|�|��dSr(�rQr5s  rr6zOrderedMultiDict.__delitem__�s������
�
�
�
�
rc�>�d�|���D��S)Nc3� K�|]	\}}|V��
dSr(r[�r�r!r"s   rr�z(OrderedMultiDict.keys.<locals>.<genexpr>�s&����3�3�
��U��3�3�3�3�3�3rrrrs rrlzOrderedMultiDict.keys�s��3�3�d�j�j�l�l�3�3�3�3rc�D�t|�����Sr(�rrlrs rr�zOrderedMultiDict.__iter__�����D�I�I�K�K� � � rc�>�d�|���D��S)Nc3� K�|]	\}}|V��
dSr(r[rs   rr�z*OrderedMultiDict.values.<locals>.<genexpr>�s&����5�5�*�#�u��5�5�5�5�5�5rrrrs rr�zOrderedMultiDict.values�s��5�5��
�
���5�5�5�5rFc#�K�|j}|r|�|j|jfV�|j}|�dSdSt	��}|�>|j|vr*|�|j��|j|jfV�|j}|�<dSdSr()rr!r"r��setr�)rr�ptr�
returned_keyss    rrzOrderedMultiDict.items�s������ ���
	��/��g�s�y�(�(�(�(��h���/�/�/�/�/� �E�E�M��/��7�-�/�/�!�%�%�c�g�.�.�.��'�3�9�,�,�,�,��h��	�/�/�/�/�/rc#��K�t��}|j}|�Q|j|vr=|j|�|j��fV�|�|j��|j}|�OdSdSr()r&rr!r�r�r�)rr(r's   rr�zOrderedMultiDict.lists�sv�������
�� ���o��w�m�+�+��g�t�|�|�C�G�4�4�4�4�4�4��!�!�#�'�*�*�*��(�C�	�o�o�o�o�orc#�FK�|���D]	\}}|V��
dSr(�r�)r�_keyr�s   rr�zOrderedMultiDict.listvalues�s6���� �J�J�L�L�	�	�L�D�&��L�L�L�L�	�	rc��t�||g���t|||����dSr()rryrDr�r?s   rr�zOrderedMultiDict.add�s8������c�2�&�&�-�-�k�$��U�.K�.K�L�L�L�L�Lrc��	t�||��}n#t$rgcYSwxYw|�d�|D��Sg}|D]6}	|�||j�����'#t
$rY�3wxYw|S)Nc��g|]	}|j��
Sr[�r"�r��xs  r�
<listcomp>z,OrderedMultiDict.getlist.<locals>.<listcomp>s��(�(�(��A�G�(�(�(r)rr�r�rDr"r�r�s      rr�zOrderedMultiDict.getlist�s���	��!�!�$��,�,�B�B���	�	�	��I�I�I�	�����<�(�(�R�(�(�(�(����	�	�D�
��
�
�d�d�4�:�.�.�/�/�/�/���
�
�
���
�����
s��-�-�#A)�)
A6�5A6c�f�|�|��|D]}|�||���dSr(r)rr!r�r"s    rr�zOrderedMultiDict.setlistsD�����S�����	!�	!�E��H�H�S�%� � � � �	!�	!rc� �td���)Nz5setlistdefault is unsupported for ordered multi dicts)rr�s   rr�zOrderedMultiDict.setlistdefaults���O�P�P�Prc�h�t|��D]!\}}t�|||���"dSr()r$rr�r�s    rr~zOrderedMultiDict.updatesB��*�7�3�3�	3�	3�J�C��� � ��s�E�2�2�2�2�	3�	3rc��t�||d��}|D]}|�|���d�|D��S)Nr[c��g|]	}|j��
Sr[r0r1s  rr3z,OrderedMultiDict.poplist.<locals>.<listcomp>s��)�)�)�A���)�)�)r)rrQr)rr!�buckets�buckets    rr�zOrderedMultiDict.poplistsO���(�(�4��b�)�)���	 �	 �F��M�M�$�����)�)��)�)�)�)rc���	t�||��}n0#t$r#|tur|cYSt	j|��d�wxYw|D]}|�|���|djSr)rrQr�rrr�rr")rr!rxr9r:s     rrQzOrderedMultiDict.pops���	?��h�h�t�S�)�)�G�G���	?�	?�	?��h�&�&������/��4�4�$�>�		?�����	 �	 �F��M�M�$������q�z��s��A�Ac��	t�|��\}}n2#t$r%}tj|jd��d�d}~wwxYw|D]}|�|���||djfSr)rr�r�rr�r|rr"�rr!r9r�r:s     rr�zOrderedMultiDict.popitem+s���	E��<�<��-�-�L�C�����	E�	E�	E��/���q�	�:�:��D�����	E�����	 �	 �F��M�M�$������G�A�J�$�$�$�� �
A� A
�
Ac���	t�|��\}}n2#t$r%}tj|jd��d�d}~wwxYw|D]}|�|���|d�|D��fS)Nrc��g|]	}|j��
Sr[r0r1s  rr3z0OrderedMultiDict.popitemlist.<locals>.<listcomp>?s��.�.�.��Q�W�.�.�.r)rr�r�rr�r|rr=s     rr�zOrderedMultiDict.popitemlist6s���	E��<�<��-�-�L�C�����	E�	E�	E��/���q�	�:�:��D�����	E�����	 �	 �F��M�M�$������.�.�g�.�.�.�.�.r>r(r�)rrXrYrZrirr-r1r�r�r�r@r6rlr�r�rr�r�r�r�r�r�r~r�rrQr�r�r[rrrr�s�������
�
�3�3�3�3����2�H�;�;�;�,�,�,�!�!�!�
1�1�1�
������4�4�4�!�!�!�6�6�6�����������M�M�M�
�
�
�
�!�!�!�
Q�Q�Q�Q�3�3�3�*�*�*� (� � � � �	%�	%�	%�	/�	/�	/�	/�	/rrc�d�tj|d�|���D����S)Nc�B�i|]\}}|�dd��|��S)�_�-)�replace�r�r�r#s   r�
<dictcomp>z'_options_header_vkw.<locals>.<dictcomp>Ds,��>�>�>�4�1�a��	�	�#�s�#�#�Q�>�>�>r)�http�dump_options_headerr)r"r�s  r�_options_header_vkwrJBs3���#�
�>�>�2�8�8�:�:�>�>�>���rc��t|t��r|�d��}t|t��st|��}|S)Nzlatin-1)r�bytes�decode�strr0s r�_unicodify_header_valuerOHsG���%����(����Y�'�'���e�S�!�!���E�
�
���Lrc���eZdZdZd%d�Zd&d�Zd�ZdZd'd�Zd(d�Z	d	�Z
d&d
�Zd&d�Zd�Z
d
�Zd)d�Zd�Zdefd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d �Z!d!�Z"d"�Z#d#�Z$d$�Z%dS)*�HeadersaCAn object that stores some headers. It has a dict-like interface,
    but is ordered, can store the same key multiple times, and iterating
    yields ``(key, value)`` pairs instead of only keys.

    This data structure is useful if you want a nicer way to handle WSGI
    headers which are stored as tuples in a list.

    From Werkzeug 0.3 onwards, the :exc:`KeyError` raised by this class is
    also a subclass of the :class:`~exceptions.BadRequest` HTTP exception
    and will render a page for a ``400 BAD REQUEST`` if caught in a
    catch-all for HTTP exceptions.

    Headers is mostly compatible with the Python :class:`wsgiref.headers.Headers`
    class, with the exception of `__getitem__`.  :mod:`wsgiref` will return
    `None` for ``headers['missing']``, whereas :class:`Headers` will raise
    a :class:`KeyError`.

    To create a new ``Headers`` object, pass it a list, dict, or
    other ``Headers`` object with default values. These values are
    validated the same way values added later are.

    :param defaults: The list of default values for the :class:`Headers`.

    .. versionchanged:: 2.1.0
        Default values are validated the same as values added later.

    .. versionchanged:: 0.9
       This data structure now stores unicode values similar to how the
       multi dicts do it.  The main difference is that bytes can be set as
       well which will automatically be latin1 decoded.

    .. versionchanged:: 0.9
       The :meth:`linked` function was removed without replacement as it
       was an API that does not support the changes to the encoding model.
    Nc�F�g|_|�|�|��dSdSr()�_listrI)r�defaultss  rrizHeaders.__init__us/����
����K�K��!�!�!�!�!� �rFc���|sWt|t��r
|j|St|t��r |�|j|��St|t
��st
j|���|���}|jD]!\}}|���|kr|cS�"|rt���t
j|���r()
r�intrS�slicernrNrr��lowerr�)rr!�	_get_mode�ikeyr�r#s      rr�zHeaders.__getitem__zs����	7��#�s�#�#�
7��z�#��&��C��'�'�
7��~�~�d�j��o�6�6�6��#�s�#�#�	5��/��4�4�4��y�y�{�{���J�	�	�D�A�q��w�w�y�y�D� � �����!�
�	��*�*���+�C�0�0�0rc��d�}|j|juoEtt||j����tt||j����kS)Nc�N�|d���f|dd�zS�Nrr
�rX)rCs r�loweredzHeaders.__eq__.<locals>.lowered�s$����G�M�M�O�O�%��Q�R�R��0�0r)rnr&�maprS)rr:r_s   rrzHeaders.__eq__�s`��	1�	1�	1���$�.�0�+�S�����%�%�6
�6
�
��W�d�j�)�)�
*�
*�6+�	+rc���	|�|d���}n#t$r|cYSwxYw|r|�d��}|�|S	||��S#t$r|cYSwxYw)a�Return the default value if the requested data doesn't exist.
        If `type` is provided and is a callable it should convert the value,
        return it or raise a :exc:`ValueError` if that is not possible.  In
        this case the function will return the default as if the value was not
        found:

        >>> d = Headers([('Content-Length', '42')])
        >>> d.get('Content-Length', type=int)
        42

        .. versionadded:: 0.9
           Added support for `as_bytes`.

        :param key: The key to be looked up.
        :param default: The default value to be returned if the key can't
                        be looked up.  If not further specified `None` is
                        returned.
        :param type: A callable that is used to cast the value in the
                     :class:`Headers`.  If a :exc:`ValueError` is raised
                     by this callable the default value is returned.
        :param as_bytes: return bytes instead of strings.
        T�rY�latin1)r�r��encoder�)rr!rxr�as_bytesr,s      rr�zHeaders.get�s���.	��!�!�#��!�6�6�B�B���	�	�	��N�N�N�	�����	%����8�$�$�B��<��I�	��4��8�8�O���	�	�	��N�N�N�	���s��)�)�
A�A"�!A"c��|���}g}|D]h\}}|���|krK|r|�d��}|�	||��}n#t$rY�OwxYw|�|���i|S)a�Return the list of items for a given key. If that key is not in the
        :class:`Headers`, the return value will be an empty list.  Just like
        :meth:`get`, :meth:`getlist` accepts a `type` parameter.  All items will
        be converted with the callable defined there.

        .. versionadded:: 0.9
           Added support for `as_bytes`.

        :param key: The key to be looked up.
        :param type: A callable that is used to cast the value in the
                     :class:`Headers`.  If a :exc:`ValueError` is raised
                     by this callable the value will be removed from the list.
        :return: a :class:`list` of all the values for the key.
        :param as_bytes: return bytes instead of strings.
        rc)rXrdr�rD)rr!rrerZr�r�r#s        rr�zHeaders.getlist�s��� �y�y�{�{�����		!�		!�D�A�q��w�w�y�y�D� � ��+�����*�*�A��#�!� �D��G�G����%�!�!�!� ��!�����
�
�a� � � ���
s�A�
A)�(A)c�,�|�|��S)z�Return a list of all the values for the named field.

        This method is compatible with the :mod:`wsgiref`
        :meth:`~wsgiref.headers.Headers.get_all` method.
        )r��rr�s  r�get_allzHeaders.get_all�s���|�|�D�!�!�!rc#�RK�|D]!\}}|r|���}||fV��"dSr(r^)rrXr!r"s    rrz
Headers.items�sK�����	�	�J�C���
"��i�i�k�k���u�*�����	�	rc#�HK�|�|��D]	\}}|V��
dSr(rr)rrXr!rCs    rrlzHeaders.keys�s:�����j�j��'�'�	�	�F�C���I�I�I�I�	�	rc#�FK�|���D]	\}}|V��
dSr(rr)rrCr"s   rr�zHeaders.values�s6�����
�
���	�	�H�A�u��K�K�K�K�	�	rc�&�t|��dkrtdt|�������|r1t|d��D]\}}|�||���t|��D]\}}|�||���dS)a�Extend headers in this object with items from another object
        containing header items as well as keyword arguments.

        To replace existing keys instead of extending, use
        :meth:`update` instead.

        If provided, the first argument can be another :class:`Headers`
        object, a :class:`MultiDict`, :class:`dict`, or iterable of
        pairs.

        .. versionchanged:: 1.0
            Support :class:`MultiDict`. Allow passing ``kwargs``.
        r
�)update expected at most 1 arguments, got rN)r�rr$r�)rr|r}r!r"s     rrIzHeaders.extend�s����t�9�9�q�=�=��S��D�	�	�S�S�T�T�T��	%�.�t�A�w�7�7�
%�
%�
��U�����e�$�$�$�$�*�6�2�2�	!�	!�J�C���H�H�S�%� � � � �	!�	!rTc��|r&t|ttf��r
|j|=dS|���}g}|jD]4\}}|���|kr|�||f���5||jdd�<dSr()rrVrWrSrXrD)rr!�_index_operation�newr�r#s      rr6zHeaders.__delitem__s����	�
�3��e�� =� =�	��
�3���F��i�i�k�k�����J�	#�	#�D�A�q��w�w�y�y�C����
�
�A�q�6�"�"�"����
�1�1�1�
�
�
rc�0�|�|d���S)zBRemove a key.

        :param key: The key to be removed.
        F)rp)r6r5s  rrFzHeaders.removes��
����e��<�<�<rc��|�|j���St|t��r|j�|��S	||}|�|��n#t
$r|tur|cYS�wxYw|S)aQRemoves and returns a key or index.

        :param key: The key to be popped.  If this is an integer the item at
                    that position is removed, if it's a string the value for
                    that key is.  If the key is omitted or `None` the last
                    item is removed.
        :return: an item.
        )rSrQrrVrFr�r)rr!rxr,s    rrQzHeaders.pops����;��:�>�>�#�#�#��c�3���	'��:�>�>�#�&�&�&�	��c��B��K�K��������	�	�	��h�&�&������	�����	s�A*�*B�Bc�*�|���S)z7Removes a key or index and returns a (key, value) item.rrs rr�zHeaders.popitem/s���x�x�z�z�rc�Z�	|�|d���n#t$rYdSwxYwdS)zCheck if a key is present.TrbF)r�r�r5s  r�__contains__zHeaders.__contains__3sJ��	����S�D��1�1�1�1���	�	�	��5�5�	�����ts��
(�(c�*�t|j��S)zYield ``(key, value)`` tuples.)rrSrs rr�zHeaders.__iter__;s���D�J���rc�*�t|j��Sr()r�rSrs r�__len__zHeaders.__len__?s���4�:���rc���|rt||��}t|��}t|��}|�|��|j�||f��dS)aAdd a new header tuple to the list.

        Keyword arguments can specify additional parameters for the header
        value, with underscores converted to dashes::

        >>> d = Headers()
        >>> d.add('Content-Type', 'text/plain')
        >>> d.add('Content-Disposition', 'attachment', filename='foo.png')

        The keyword argument dumping uses :func:`dump_options_header`
        behind the scenes.

        .. versionadded:: 0.4.1
            keyword arguments were added for :mod:`wsgiref` compatibility.
        N)rJrO�_validate_valuerSrD�rr,�_valuer�s    rr�zHeaders.addBsi�� �	5�(���4�4�F�&�t�,�,��(��0�0�����V�$�$�$��
���4��.�)�)�)�)�)rc�|�t|t��std���d|vsd|vrtd���dS)NzValue should be a string.�
�
zGDetected newline in header value.  This is a potential security problem)rrNrr�r�s  rr{zHeaders._validate_valueYsR���%��%�%�	9��7�8�8�8��5�=�=�D�E�M�M��/���
�*�Mrc�$�|j||fi|��dS)z�Add a new header tuple to the list.

        An alias for :meth:`add` for compatibility with the :mod:`wsgiref`
        :meth:`~wsgiref.headers.Headers.add_header` method.
        N)r��rr,r}�_kws    r�
add_headerzHeaders.add_headerbs&��	����v�%�%��%�%�%�%�%rc��|jdd�=dS)zClears all headers.N)rSrs rr�z
Headers.clearjs���J�q�q�q�M�M�Mrc���|rt||��}t|��}t|��}|�|��|js|j�||f��dSt|j��}|����t|��D].\}\}}|����kr||f|j|<n�/|j�||f��dS�fd�|D��|j|dzd�<dS)a0Remove all header tuples for `key` and add a new one.  The newly
        added key either appears at the end of the list if there was no
        entry or replaces the first one.

        Keyword arguments can specify additional parameters for the header
        value, with underscores converted to dashes.  See :meth:`add` for
        more information.

        .. versionchanged:: 0.6.1
           :meth:`set` now accepts the same arguments as :meth:`add`.

        :param key: The key to be inserted.
        :param value: The value to be inserted.
        Nc�P��g|]"}|d����k� |��#S)rr^)r��trZs  �rr3zHeaders.set.<locals>.<listcomp>�s/��� M� M� M�q��!��
�
����8L�8L��8L�8L�8Lrr
)rJrOr{rSrDrrX�	enumerate)	rr,r}r��listiter�idx�old_key�
_old_valuerZs	        @rr&zHeaders.setns+����	5�(���4�4�F�&�t�,�,��(��0�0�����V�$�$�$��z�	��J���t�V�n�-�-�-��F���
�#�#���z�z�|�|��*3�H�*=�*=�	�	�&�C�&�'�:��}�}���$�&�&�#'��.��
�3����'�

�J���t�V�n�-�-�-��F� M� M� M� M�H� M� M� M��
�3��7�9�9���rc���|rOt|��}|�|t|����|D]}|�||���dS|�|��dS)z�Remove any existing values for a header and add new ones.

        :param key: The header key to set.
        :param values: An iterable of values to set for the key.

        .. versionadded:: 1.0
        N)rr&r�r�rF)rr!r��values_iterr"s     rr�zHeaders.setlist�s}���	��v�,�,�K��H�H�S�$�{�+�+�,�,�,�$�
%�
%������e�$�$�$�$�
%�
%�
�K�K������rc�J�||vr||S|�||��|S)a*Return the first value for the key if it is in the headers,
        otherwise set the header to the value given by ``default`` and
        return that.

        :param key: The header key to get.
        :param default: The value to set for the key if it is not in the
            headers.
        �r&rws   rryzHeaders.setdefault�s0���$�;�;���9������g�����rc�`�||vr|�||��|�|��S)a�Return the list of values for the key if it is in the
        headers, otherwise set the header to the list of values given
        by ``default`` and return that.

        Unlike :meth:`MultiDict.setlistdefault`, modifying the returned
        list will not affect the headers.

        :param key: The header key to get.
        :param default: An iterable of values to set for the key if it
            is not in the headers.

        .. versionadded:: 1.0
        )r�r�rws   rr�zHeaders.setlistdefault�s3���d�?�?��L�L��g�&�&�&��|�|�C� � � rc�R�t|ttf��rtt|t��r|g}d�|D��}|D]\}}|�|���t|t��r|d|j|<dS||j|<dS|�||��dS)z=Like :meth:`set` but also supports index/slice based setting.c�P�g|]#\}}t|��t|��f��$Sr[)rOrFs   rr3z'Headers.__setitem__.<locals>.<listcomp>�sB������Q��)��+�+�-D�Q�-G�-G�H���rrN)rrWrVr{rSr&)rr!r"rCr#s     rr@zHeaders.__setitem__�s����c�E�3�<�(�(�	!��#�s�#�#�
 ������#����E� �
(�
(���A��$�$�Q�'�'�'�'��#�s�#�#�
(�"'��(��
�3����"'��
�3�����H�H�S�%� � � � � rc�,�t|��dkrtdt|�������|r�|d}t|ttf��rA|���D]+}|�||�|�����,n�t|t��rd|�	��D]N\}}t|ttf��r|�||���8|�||���On|D]\}}|�||���|�	��D]N\}}t|ttf��r|�||���8|�||���OdS)a�Replace headers in this object with items from another
        headers object and keyword arguments.

        To extend existing keys instead of replacing, use :meth:`extend`
        instead.

        If provided, the first argument can be another :class:`Headers`
        object, a :class:`MultiDict`, :class:`dict`, or iterable of
        pairs.

        .. versionadded:: 1.0
        r
rnrN)
r�rrrQrrlr�r�rrrrr&)rr|r}r r!r"s      rr~zHeaders.update�s����t�9�9�q�=�=��S��D�	�	�S�S�T�T�T��	)��1�g�G��'�G�Y�#7�8�8�
)�"�<�<�>�>�<�<�C��L�L��g�o�o�c�&:�&:�;�;�;�;�<��G�T�*�*�
)�")�-�-�/�/�-�-�J�C��!�%�$���7�7�-����S�%�0�0�0�0�����e�,�,�,�,�	-�#*�)�)�J�C���H�H�S�%�(�(�(�(� �,�,�.�.�	%�	%�J�C���%�$���/�/�
%����S�%�(�(�(�(�����e�$�$�$�$�		%�	%rc� �t|��S)zRConvert the headers into a list suitable for WSGI.

        :return: list
        )rrs r�to_wsgi_listzHeaders.to_wsgi_list����
�D�z�z�rc�6�|�|j��Sr()rnrSrs rr�zHeaders.copys���~�~�d�j�)�)�)rc�*�|���Sr(r�rs rr�zHeaders.__copy__r�rc���g}|���D]\}}|�|�d|����� |�d��d�|��S)z9Returns formatted headers suitable for HTTP transmission.�: z
)r�rD�join)r�strsr!r"s    r�__str__zHeaders.__str__	sm�����+�+�-�-�	+�	+�J�C���K�K�3�)�)�%�)�)�*�*�*�*����F�����{�{�4� � � rc�P�t|��j�dt|���d�Sr_)rrrrs rrbzHeaders.__repr__s(���t�*�*�%�7�7��T�
�
�7�7�7�7rr(r��NNFrWr�)&rrXrYrZrir�rr-r�r�rirrlr�rIr6rFrrQr�rvr�ryr�r{r�r�r&r�ryr�r@r~r�r�r�r�rbr[rrrQrQPs;������"�"�H"�"�"�"�
1�1�1�1�&+�+�+��H�"�"�"�"�H����<"�"�"������������!�!�!�0	�	�	�	�=�=�=��H�����,������ � � ����*�*�*�.���&�&�&����!N�!N�!N�F���"
�
�
�!�!�!�&!�!�!�$$%�$%�$%�L���*�*�*����!�!�!�8�8�8�8�8rrQc�l�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
defd
�Zd�Zd�Zd�ZdS)�ImmutableHeadersMixinz�Makes a :class:`Headers` immutable.  We do not mark them as
    hashable though since the only usecase for this datastructure
    in Werkzeug is a view on a mutable structure.

    .. versionadded:: 0.5

    :private:
    c�$�t|��dSr(r4)rr!r}s   rr6z!ImmutableHeadersMixin.__delitem__r7rc�$�t|��dSr(r4r?s   rr@z!ImmutableHeadersMixin.__setitem__"r7rc�$�t|��dSr(r4r|s    rr&zImmutableHeadersMixin.set%r7rc�$�t|��dSr(r4r�s   rr�zImmutableHeadersMixin.setlist(r7rc�$�t|��dSr(r4r|s    rr�zImmutableHeadersMixin.add+r7rc�$�t|��dSr(r4r�s    rr�z ImmutableHeadersMixin.add_header.r7rc�$�t|��dSr(r4r5s  rrFzImmutableHeadersMixin.remove1r7rc�$�t|��dSr(r4r{s   rrIzImmutableHeadersMixin.extend4r7rc�$�t|��dSr(r4r{s   rr~zImmutableHeadersMixin.update7r7rc�$�t|��dSr(r4rKs   rrMzImmutableHeadersMixin.insert:r7rNc�$�t|��dSr(r4rws   rrQzImmutableHeadersMixin.pop=r7rc�$�t|��dSr(r4rs rr�zImmutableHeadersMixin.popitem@r7rc�$�t|��dSr(r4rws   rryz ImmutableHeadersMixin.setdefaultCr7rc�$�t|��dSr(r4rws   rr�z$ImmutableHeadersMixin.setlistdefaultFr7r)rrXrYrZr6r@r&r�r�r�rFrIr~rMrrQr�ryr�r[rrr�r�s����������������������������������������H���������������rr�c�<�eZdZdZd�Zd�ZdZd
d�Zd�Zd�Z	d	�Z
dS)�EnvironHeadersa�Read only version of the headers from a WSGI environment.  This
    provides the same interface as `Headers` and is constructed from
    a WSGI environment.

    From Werkzeug 0.3 onwards, the `KeyError` raised by this class is also a
    subclass of the :exc:`~exceptions.BadRequest` HTTP exception and will
    render a page for a ``400 BAD REQUEST`` if caught in a catch-all for
    HTTP exceptions.
    c��||_dSr(��environ)rr�s  rrizEnvironHeaders.__init__Us
������rc��|j|juSr(r�r9s  rrzEnvironHeaders.__eq__Xs���|�u�}�,�,rNFc��t|t��st|���|����dd��}|dvrt|j|��St|jd|����S)NrDrC��CONTENT_TYPE�CONTENT_LENGTH�HTTP_)rrNr��upperrErOr�)rr!rYs   rr�zEnvironHeaders.__getitem__]s{���#�s�#�#�	 ��3�-�-���i�i�k�k�!�!�#�s�+�+���4�4�4�*�4�<��+<�=�=�=�&�t�|�M�C�M�M�'B�C�C�Crc�T�ttt|������Sr()r�rrrs rryzEnvironHeaders.__len__gs ���4��T�
�
�#�#�$�$�$rc#�|K�|j���D]�\}}|�d��rF|dvrB|dd��dd�����t|��fV��`|dvr;|r9|�dd�����t|��fV���dS)Nr�)�HTTP_CONTENT_TYPE�HTTP_CONTENT_LENGTH�rCrDr�)r�r�
startswithrE�titlerOr?s   rr�zEnvironHeaders.__iter__ls������,�,�,�.�.�
	V�
	V�J�C���~�~�g�&�&�	
V�3�7�,�,�
����G�O�O�C��-�-�3�3�5�5�+�E�2�2�������:�:�:�u�:��{�{�3��,�,�2�2�4�4�6M�e�6T�6T�U�U�U�U��
	V�
	Vrc�L�tdt|��j�d����)N�cannot create z copiesrrs rr�zEnvironHeaders.copyys%���G��d���)<�G�G�G�H�H�Hrr�)rrXrYrZrirr-r�ryr�r�r[rrr�r�Js������������-�-�-��H�D�D�D�D�%�%�%�
V�V�V�I�I�I�I�Irr�c��eZdZdZd�Zdd�Zedd���Zd�Zdd�Z	dd�Z
d	�Zd
�Zd�Z
dd
�Zd�Zd�Zd�Zd�Zdd�Zd�Zd�Zd�ZdS)�CombinedMultiDicta>A read only :class:`MultiDict` that you can pass multiple :class:`MultiDict`
    instances as sequence and it will combine the return values of all wrapped
    dicts:

    >>> from werkzeug.datastructures import CombinedMultiDict, MultiDict
    >>> post = MultiDict([('foo', 'bar')])
    >>> get = MultiDict([('blub', 'blah')])
    >>> combined = CombinedMultiDict([get, post])
    >>> combined['foo']
    'bar'
    >>> combined['blub']
    'blah'

    This works for all read operations and will raise a `TypeError` for
    methods that usually change data which isn't possible.

    From Werkzeug 0.3 onwards, the `KeyError` raised by this class is also a
    subclass of the :exc:`~exceptions.BadRequest` HTTP exception and will
    render a page for a ``400 BAD REQUEST`` if caught in a catch-all for HTTP
    exceptions.
    c�0�t|��|jffSr()r�dictsr/s  rr1zCombinedMultiDict.__reduce_ex__�s���D�z�z�D�J�=�(�(rNc�2�t|��pg|_dSr()rr�)rr�s  rrizCombinedMultiDict.__init__�s���%�[�[�&�B��
�
�
rc�2�td|j�d����)Nr�z instances by fromkeys)rr)rkrlr"s   rrozCombinedMultiDict.fromkeys�s���O���O�O�O�P�P�Prc�Z�|jD]}||vr
||cS�tj|���r()r�rr��rr!�ds   rr�zCombinedMultiDict.__getitem__�s?����	�	�A��a�x�x���v�
�
�
���+�C�0�0�0rc��|jD]6}||vr0|�$	|||��cS#t$rY�(wxYw||cS�7|Sr()r�r�)rr!rxrr�s     rr�zCombinedMultiDict.get�sx����	�	�A��a�x�x��#�!�#�t�A�c�F�|�|�+�+�+��%�!�!�!� ��!������v�
�
�
�
��s�$�
1�1c�p�g}|jD]+}|�|�||�����,|Sr()r�rIr�)rr!rr,r�s     rr�zCombinedMultiDict.getlist�s@��
����	,�	,�A��I�I�a�i�i��T�*�*�+�+�+�+��	rc�@�t��}|j|j�|S)z�This function exists so __len__ can be implemented more efficiently,
        saving one list creation from an iterator.
        )r&r~r�r+s  r�
_keys_implzCombinedMultiDict._keys_impl�s#���U�U����	�4�:����	rc�*�|���Sr()r�rs rrlzCombinedMultiDict.keys�s����� � � rc�D�t|�����Sr(r!rs rr�zCombinedMultiDict.__iter__�r"rFc#�K�t��}|jD]E}|�|��D]-\}}|r||fV��||vr|�|��||fV��.�FdSr()r&r�rr�)rr�foundr�r!r"s      rrzCombinedMultiDict.items�s�����������	%�	%�A��g�g�e�n�n�
%�
%�
��U��%��u�*�$�$�$�$���%�%��I�I�c�N�N�N��u�*�$�$�$��
%�	%�	%rc#�FK�|���D]	\}}|V��
dSr(rr)rr,r"s   rr�zCombinedMultiDict.values�s6�����:�:�<�<�	�	�K�D�%��K�K�K�K�	�	rc���i}|jD]E}|���D].\}}|�|g���|���/�Ft	|�����Sr()r�r�ryrIrr)rr,r�r!r�s     rr�zCombinedMultiDict.lists�ss��
����	6�	6�A� �w�w�y�y�
6�
6���V��
�
�c�2�&�&�-�-�f�5�5�5�5�
6��B�H�H�J�J���rc�>�d�|���D��S)Nc3�&K�|]}|dV��
dS)r
Nr[r1s  rr�z/CombinedMultiDict.listvalues.<locals>.<genexpr>�s&����+�+���!��+�+�+�+�+�+rr+rs rr�zCombinedMultiDict.listvalues�s��+�+�d�j�j�l�l�+�+�+�+rc� �t|��S)a0Return a shallow mutable copy of this object.

        This returns a :class:`MultiDict` representing the data at the
        time of copying. The copy will no longer reflect changes to the
        wrapped dicts.

        .. versionchanged:: 0.15
            Return a mutable :class:`MultiDict`.
        �rrs rr�zCombinedMultiDict.copy�s������rTc��|r!t|�����St|�����S)a�Return the contents as regular dict.  If `flat` is `True` the
        returned dict will only have the first item present, if `flat` is
        `False` all values will be returned as lists.

        :param flat: If set to `False` the dict returned will have lists
                     with all the values in it.  Otherwise it will only
                     contain the first item for each key.
        :return: a :class:`dict`
        r�r�s  rr�zCombinedMultiDict.to_dict�s8���	&���
�
���%�%�%��D�J�J�L�L�!�!�!rc�D�t|�����Sr()r�r�rs rryzCombinedMultiDict.__len__�s���4�?�?�$�$�%�%�%rc�(�|jD]	}||vrdS�
dS�NTF)r�r�s   rrvzCombinedMultiDict.__contains__�s-����	�	�A��a�x�x��t�t���urc�@�t|��j�d|j�d�Sr_)rrr�rs rrbzCombinedMultiDict.__repr__�s$���t�*�*�%�7�7��
�7�7�7�7rr(r�r�r�)rrXrYrZr1rir�ror�r�r�r�rlr�rr�r�r�r�r�ryrvrbr[rrr�r�}sZ��������,)�)�)�'�'�'�'��Q�Q�Q��[�Q�1�1�1�	�	�	�	��������!�!�!�!�!�!�%�%�%�%���� � � �,�,�,�
�
�
�
"�
"�
"�
"�&�&�&����8�8�8�8�8rr�c��eZdZdZdd�ZdS)�
FileMultiDictz�A special :class:`MultiDict` that has convenience methods to add
    files to it.  This is used for :class:`EnvironBuilder` and generally
    useful for unittesting.

    .. versionadded:: 0.5
    Nc��t|t��r|}n[t|t��r|�|}t|d��}|r|�t	j|��dpd}t||||��}|�||��dS)aPAdds a new file to the dict.  `file` can be a file name or
        a :class:`file`-like or a :class:`FileStorage` object.

        :param name: the name of the field.
        :param file: a filename or :class:`file`-like object
        :param filename: an optional filename
        :param content_type: an optional content type
        N�rbrzapplication/octet-stream)r�FileStoragerN�open�	mimetypes�
guess_typer�)rr��file�filename�content_typer"s      r�add_filezFileMultiDict.add_files����d�K�(�(�	D��E�E��$��$�$�
(��#�#�H��D�$�'�'���
�L�0��(��2�2�1�5�S�9S�� ��h��l�C�C�E�����u�����rr�)rrXrYrZr�r[rrr�r�s2�������������rr�c�$�eZdZdZd�Zd�Zd�ZdS)�
ImmutableDictz;An immutable :class:`dict`.

    .. versionadded:: 0.5
    c�f�t|��j�dt�|���d�Sr_�rrrrbrs rrbzImmutableDict.__repr__*rcrc� �t|��Sr�)rrs rr�zImmutableDict.copy-r�rc��|Sr(r[rs rr�zImmutableDict.__copy__4r�rN)rrXrYrZrbr�r�r[rrr�r�$sK��������
?�?�?��������rr�c��eZdZdZd�Zd�ZdS)�ImmutableMultiDictz@An immutable :class:`MultiDict`.

    .. versionadded:: 0.5
    c� �t|��Sr�r�rs rr�zImmutableMultiDict.copy>s��
����rc��|Sr(r[rs rr�zImmutableMultiDict.__copy__Er�rNr�r[rrr�r�8s<��������
�������rr�c�$�eZdZdZd�Zd�Zd�ZdS)�ImmutableOrderedMultiDictzGAn immutable :class:`OrderedMultiDict`.

    .. versionadded:: 0.6
    c�H�t|�d�����Sr�)r�rrs rrsz)ImmutableOrderedMultiDict._iter_hashitemsOs������$��/�/�0�0�0rc� �t|��Sr�)rrs rr�zImmutableOrderedMultiDict.copyRs��
 ��%�%�%rc��|Sr(r[rs rr�z"ImmutableOrderedMultiDict.__copy__Yr�rN)rrXrYrZrsr�r�r[rrr�r�IsK��������
1�1�1�&�&�&�����rr�c��eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zdd�Zed���ZdS)�Accepta�An :class:`Accept` object is just a list subclass for lists of
    ``(value, quality)`` tuples.  It is automatically sorted by specificity
    and quality.

    All :class:`Accept` objects work similar to a list but provide extra
    functionality for working with the data.  Containment checks are
    normalized to the rules of that header:

    >>> a = CharsetAccept([('ISO-8859-1', 1), ('utf-8', 0.7)])
    >>> a.best
    'ISO-8859-1'
    >>> 'iso-8859-1' in a
    True
    >>> 'UTF8' in a
    True
    >>> 'utf7' in a
    False

    To get the quality for an item you can use normal item lookup:

    >>> print a['utf-8']
    0.7
    >>> a['utf7']
    0

    .. versionchanged:: 0.5
       :class:`Accept` objects are forced immutable now.

    .. versionchanged:: 1.0.0
       :class:`Accept` internal values are no longer ordered
       alphabetically for equal quality tags. Instead the initial
       order is preserved.

    r[c�<��|�#t����d�_dSt|t��r)|j�_t��|��dSd�_t|�fd�d���}t��|��dS)NFTc�J����|d��|dfSr])�_specificity)r2rs �r�<lambda>z!Accept.__init__.<locals>.<lambda>�s"���t�'8�'8��1��'>�'>��!��&E�r)r!rS)rri�providedrr��sortedr�s` rrizAccept.__init__�s�����>��M�M�$����!�D�M�M�M�
���
'�
'�	(�"�O�D�M��M�M�$��'�'�'�'�'� �D�M���E�E�E�E�t����F�
�M�M�$��'�'�'�'�'rc��|dkfS)z3Returns a tuple describing the value's specificity.�*r[r�s  rrzAccept._specificity�s������rc�b�|dkp)|���|���kS)z-Check if a value matches a given accept item.rr^�rr"rCs   r�_value_matcheszAccept._value_matches�s&���s�{�;�d�j�j�l�l�e�k�k�m�m�;�;rc��t|t��r|�|��St�||��S)z�Besides index lookup (getting item n) you can also pass it a string
        to get the quality for the item.  If the item is not in the list, the
        returned quality is ``0``.
        )rrN�qualityrr�r5s  rr�zAccept.__getitem__�s>��
�c�3���	%��<�<��$�$�$�����c�*�*�*rc�J�|D]\}}|�||��r|cS� dS)z�Returns the quality of the key.

        .. versionadded:: 0.6
           In previous versions you had to use the item-lookup syntax
           (eg: ``obj[key]`` instead of ``obj.quality(key)``)
        r�r
)rr!rCrs    rrzAccept.quality�sB��"�	�	�M�D�'��"�"�3��-�-�
�����
��qrc�H�|D]\}}|�||��rdS�dSr�r)rr"rC�_qualitys    rrvzAccept.__contains__�s>��"�	�	�N�D�(��"�"�5�$�/�/�
��t�t�
��urc�t�d�d�|D����}t|��j�d|�d�S)N�, c3�.K�|]\}}d|�d|�d�V��dS)r`rraNr[)r�r2�ys   rr�z"Accept.__repr__.<locals>.<genexpr>�s4����?�?�$�!�Q�o�!�o�o��o�o�o�?�?�?�?�?�?rz([z]))r�rr)r�	pairs_strs  rrbzAccept.__repr__�sB���I�I�?�?�$�?�?�?�?�?�	��t�*�*�%�6�6��6�6�6�6rc���t|t��rAt|��D]"\}\}}|�||��r|cS�#t	|���t
�||��S)z�Get the position of an entry or raise :exc:`ValueError`.

        :param key: The key to be looked up.

        .. versionchanged:: 0.5
           This used to raise :exc:`IndexError`, which was inconsistent
           with the list API.
        )rrNr�r
r�rrP)rr!r�rCrs     rrPzAccept.index�s{���c�3���	"�)2�4���
�
�%��%�d�H��&�&�s�D�1�1���J�J�J���S�/�/�!��z�z�$��$�$�$rc�P�	|�|��S#t$rYdSwxYw)zaGet the position of an entry or return -1.

        :param key: The key to be looked up.
        rN)rPr�r5s  r�findzAccept.find�s9��
	��:�:�c�?�?�"���	�	�	��2�2�	���s��
%�%c#�(K�|D]}|dV��
dS)zIterate over all values.rNr[rBs  rr�z
Accept.values�s.�����	�	�D��q�'�M�M�M�M�	�	rc��g}|D]'\}}|dkr|�d|��}|�|���(d�|��S)�2Convert the header set into an HTTP header string.r
z;q=�,)rDr�)rr�r"rs    r�	to_headerzAccept.to_header�s]����"�	!�	!�N�E�7��!�|�|� �.�.�W�.�.���M�M�%� � � � ��x�x����rc�*�|���Sr(�rrs rr�zAccept.__str__�����~�~���rc�N�|D]!\}}|�||��r||fcS�"dSr(r)r�match�client_itemrs    r�_best_single_matchzAccept._best_single_match�sK��$(�	,�	,� �K���"�"�5�+�6�6�
,�"�G�+�+�+�+�
,��trNc��|}d}d}|D]S}|�|��}|s�|\}}	|�|��}
|	dks|	|kr�A|	|ks|
|kr|}|	}|
}�T|S)aVReturns the best match from a list of possible matches based
        on the specificity and quality of the client. If two items have the
        same quality and specificity, the one is returned that comes first.

        :param matches: a list of matches to check for
        :param default: the value that is returned if none match
        rNrVr)r$r)r�matchesrxr��best_quality�best_specificity�server_itemr"r#r�specificitys           r�
best_matchzAccept.best_match�s������� ��"�	/�	/�K��+�+�K�8�8�E��
��#(� �K���+�+�K�8�8�K��!�|�|�w��5�5����%�%��7G�)G�)G�$��&��#.� ���
rc�&�|r|ddSdS)zThe best match as value.rNr[rs r�bestzAccept.bests$���	���7�1�:��	�	r)r[r()rrXrYrZrirr
r�rrvrbrPrr�rr�r$r+�propertyr-r[rrr�r�]s������!�!�F(�(�(�(����<�<�<�+�+�+�
�
�
����7�7�7�%�%�%� ������
 � � � � � ��������4����X���rr�z
/|(?:\s*;\s*)c�Z�t�|�����Sr()�_mime_split_re�splitrXr0s r�_normalize_mimer2s��������
�
�.�.�.rc�`�eZdZdZd�Zd�Zed���Zed���Zed���Z	dS)�
MIMEAcceptzRLike :class:`Accept` but with special methods and behavior for
    mimetypes.
    c�d�td�t�|��D����S)Nc3�"K�|]
}|dkV��dS)rNr[r1s  rr�z*MIMEAccept._specificity.<locals>.<genexpr>s&����C�C�!�Q�#�X�C�C�C�C�C�Cr)rr0r1r�s  rrzMIMEAccept._specificitys-���C�C�~�';�';�E�'B�'B�C�C�C�C�C�Crc���d|vrdSd|vrtd|�����t|��}|dd�\}}t|dd���}|dkr|dkrtd|�����t|��}|dd�\}}	t|dd���}
|dkr|	dkrdS|dkr|	dkp|dko|dkp||ko|	dkp|dkp|	|ko|
|kS)N�/Fzinvalid mimetype �r)r�r2r)rr"rC�normalized_value�
value_type�
value_subtype�value_params�normalized_item�	item_type�item_subtype�item_paramss           rr
zMIMEAccept._value_matchessb���d�?�?��5��e����:��:�:�;�;�;�+�5�1�1��$4�R�a�R�$8�!�
�M��.�q�r�r�2�3�3�������#�!5�!5��:��:�:�;�;�;�*�$�/�/��"1�"�1�"�"5��	�<��_�Q�R�R�0�1�1�������� 3� 3��5��#�
�
5�,�#�"5�
<��c�!�:�m�s�&:�

�
��#�
���#�S� �C�'�S� �M�1�Q�k�\�6Q�
	
rc� �d|vp
d|vp|jS)z!True if this object accepts HTML.z	text/html�application/xhtml+xml)�accept_xhtmlrs r�accept_htmlzMIMEAccept.accept_html@s$��
�4��W�#:�d�#B�W�d�FW�	
rc��d|vpd|vS)z"True if this object accepts XHTML.rCzapplication/xmlr[rs rrDzMIMEAccept.accept_xhtmlGs��'�$�.�K�2C�t�2K�Krc�
�d|vS)z!True if this object accepts JSON.zapplication/jsonr[rs r�accept_jsonzMIMEAccept.accept_jsonLs��"�T�)�)rN)
rrXrYrZrr
r.rErDrHr[rrr4r4s���������D�D�D�&
�&
�&
�P�
�
��X�
��L�L��X�L��*�*��X�*�*�*rr4z[_-]c�Z�t�|�����S)z$Process a language tag for matching.)�_locale_delim_rer1rXr0s r�_normalize_langrKUs���!�!�%�+�+�-�-�0�0�0rc�*��eZdZdZd�Zd�fd�	Z�xZS)�LanguageAcceptz>Like :class:`Accept` but with normalization for language tags.c�N�|dkpt|��t|��kS)Nr)rKr	s   rr
zLanguageAccept._value_matches]s&���s�{�M�o�e�4�4���8M�8M�M�MrNc�L���t���|������Std�|D����}|�|������Sd�|D��}t���|�����t�fd�|D����S|S)a�Given a list of supported values, finds the best match from
        the list of accepted values.

        Language tags are normalized for the purpose of matching, but
        are returned unchanged.

        If no exact match is found, this will fall back to matching
        the first subtag (primary language only), first with the
        accepted values then with the match values. This partial is not
        applied to any other language subtags.

        The default is returned if no exact or fallback match is found.

        :param matches: A list of supported languages to find a match.
        :param default: The value that is returned if none match.
        Nc�l�g|]1}t�|dd��d|df��2S)rr
�rJr1�r�rCs  rr3z-LanguageAccept.best_match.<locals>.<listcomp>|s;��O�O�O�$��$�$�T�!�W�a�0�0��3�T�!�W�
=�O�O�Orc�P�g|]#}t�|d��d��$S)r
rrQrRs  rr3z-LanguageAccept.best_match.<locals>.<listcomp>�s.��S�S�S�4�,�2�2�4��;�;�A�>�S�S�Src3�F�K�|]}|�����|V��dSr()r�)r�rCr�s  �rr�z,LanguageAccept.best_match.<locals>.<genexpr>�s4�����L�L��D�O�O�F�4K�4K�L��L�L�L�L�L�Lr)rgr+r�r�)rr&rx�fallback�fallback_matchesr�rns     @�rr+zLanguageAccept.best_match`s�����&���#�#�G�,�,�����M�
�O�O�$�O�O�O�
�
���$�$�W�-�-�����M�T�S�7�S�S�S�����#�#�$4�5�5�����L�L�L�L��L�L�L�L�L�L��rr()rrXrYrZr
r+r�r�s@rrMrMZsU�������H�H�N�N�N�-�-�-�-�-�-�-�-�-�-rrMc��eZdZdZd�ZdS)�
CharsetAcceptz9Like :class:`Accept` but with normalization for charsets.c�D�d�}|dkp||��||��kS)Nc�~�	tj|��jS#t$r|���cYSwxYwr()�codecs�lookupr��LookupErrorrX)r�s r�
_normalizez0CharsetAccept._value_matches.<locals>._normalize�sI��
$��}�T�*�*�/�/���
$�
$�
$��z�z�|�|�#�#�#�
$���s��<�<rr[)rr"rCr^s    rr
zCharsetAccept._value_matches�s;��	$�	$�	$��s�{�C�j�j��/�/�:�:�d�3C�3C�C�CrN)rrXrYrZr
r[rrrXrX�s.������C�C�D�D�D�D�DrrXc�J����t���fd���fd��fd�d�����S)z�Return a new property object for a cache header. Useful if you
    want to add support for a cache extension in a subclass.

    .. versionchanged:: 2.0
        Renamed from ``cache_property``.
    c�2��|������Sr()�_get_cache_value)r2�emptyr!rs ���rrz(cache_control_property.<locals>.<lambda>�s���!�$�$�S�%��6�6�rc�2��|��|���Sr()�_set_cache_value)r2r#r!rs  ��rrz(cache_control_property.<locals>.<lambda>�s���Q�'�'��Q��5�5�rc�.��|����Sr()�_del_cache_value�r2r!s �rrz(cache_control_property.<locals>.<lambda>�s���!�$�$�S�)�)�r�
accessor for �r.)r!rbrs```r�cache_control_propertyrj�sQ������6�6�6�6�6�6�5�5�5�5�5�)�)�)�)�����	��rc��eZdZdZeddd��Zedde��Zedde��Z	eddd��Z
dd
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zee��ZdS)�
_CacheControla�Subclass of a dict that stores values for a Cache-Control header.  It
    has accessors for all the cache-control directives specified in RFC 2616.
    The class does not differentiate between request and response directives.

    Because the cache-control directives in the HTTP header use dashes the
    python descriptors use underscores for that.

    To get a header of the :class:`CacheControl` object again you can convert
    the object into a string or call the :meth:`to_header` method.  If you plan
    to subclass it and add your own items have a look at the sourcecode for
    that class.

    .. versionchanged:: 2.1.0
        Setting int properties such as ``max_age`` will convert the
        value to an int.

    .. versionchanged:: 0.4

       Setting `no_cache` or `private` to boolean `True` will set the implicit
       none-value which is ``*``:

       >>> cc = ResponseCacheControl()
       >>> cc.no_cache = True
       >>> cc
       <ResponseCacheControl 'no-cache'>
       >>> cc.no_cache
       '*'
       >>> cc.no_cache = None
       >>> cc
       <ResponseCacheControl ''>

       In versions before 0.5 the behavior documented here affected the now
       no longer existing `CacheControl` class.
    zno-cacherNzno-storezmax-agerNzno-transformr[c�`�t�||pd��||_|du|_dS�Nr[�rrir�r�rr�r�s   rriz_CacheControl.__init__��1���
�
�d�F�L�b�)�)�)�"����d�*��
�
�
rc��|tur||vS||vr-||}|�|S|�	||��}n#t$rYnwxYw|SdS��+Used internally by the accessor properties.N)�boolr�)rr!rbrr"s     rraz_CacheControl._get_cache_value�su���4�<�<��$�;���$�;�;���I�E��}����!�� �D��K�K�E�E��!�����D������L��ts�-�
:�:c���|tur!|rd||<dS|�|d��dS|�|�|d��dS|durd||<dS|�||��||<dS|||<dS)rtNT)rurQ)rr!r"rs    rrdz_CacheControl._set_cache_value�s����4�<�<��
$� ��S�	�	�	�����d�#�#�#�#�#��}�����d�#�#�#�#�#��$��� ��S�	�	�	��#� $��U���D��I�I�I� %�D��I�I�Irc��||vr||=dSdSrsr[r5s  rrfz_CacheControl._del_cache_value�����$�;�;��S�	�	�	��;rc�*�tj|��S�z6Convert the stored values into a cache control header.)rH�dump_headerrs rrz_CacheControl.to_headers�����%�%�%rc�*�|���Sr(rrs rr�z_CacheControl.__str__r rc��d�d�t|�����D����}dt|��j�d|�d�S)N� c3�*K�|]\}}|�d|��V��dS��=Nr[rFs   rr�z)_CacheControl.__repr__.<locals>.<genexpr>	�0����H�H�4�1�a�Q�,�,��,�,�H�H�H�H�H�Hr�<�>�r�rrrr�r�kv_strs  rrbz_CacheControl.__repr__�T�����H�H�6�$�*�*�,�,�3G�3G�H�H�H�H�H��2�4��:�:�&�2�2��2�2�2�2r�r[N)rrXrYrZrj�no_cacheru�no_storerV�max_age�no_transformrirardrfrr�rb�staticmethod�cache_propertyr[rrrlrl�s�������!�!�F&�%�j�#�t�<�<�H�%�%�j�$��=�=�H�$�$�Y��C�8�8�G�)�)�.�$��E�E�L�+�+�+�+�
��� &�&�&�$���
&�&�&� � � �3�3�3�"�\�"8�9�9�N�N�Nrrlc�`�eZdZdZedde��Zedde��Zedde��Z	dS)�RequestCacheControla�A cache control for requests.  This is immutable and gives access
    to all the request-relevant cache control headers.

    To get a header of the :class:`RequestCacheControl` object again you can
    convert the object into a string or call the :meth:`to_header` method.  If
    you plan to subclass it and add your own items have a look at the sourcecode
    for that class.

    .. versionchanged:: 2.1.0
        Setting int properties such as ``max_age`` will convert the
        value to an int.

    .. versionadded:: 0.5
       In previous versions a `CacheControl` class existed that was used
       both for request and response.
    z	max-stalerz	min-freshzonly-if-cachedN)
rrXrYrZrjrV�	max_stale�	min_freshru�only_if_cachedr[rrr�r�sW��������"'�&�{�C��=�=�I�&�&�{�C��=�=�I�+�+�,<�d�D�I�I�N�N�Nrr�c��eZdZdZedde��Zeddd��Zedde��Zedde��Z	edde
��Zed	de��ZdS)
�ResponseCacheControla�A cache control for responses.  Unlike :class:`RequestCacheControl`
    this is mutable and gives access to response-relevant cache control
    headers.

    To get a header of the :class:`ResponseCacheControl` object again you can
    convert the object into a string or call the :meth:`to_header` method.  If
    you plan to subclass it and add your own items have a look at the sourcecode
    for that class.

    .. versionchanged:: 2.1.1
        ``s_maxage`` converts the value to an int.

    .. versionchanged:: 2.1.0
        Setting int properties such as ``max_age`` will convert the
        value to an int.

    .. versionadded:: 0.5
       In previous versions a `CacheControl` class existed that was used
       both for request and response.
    �publicN�privaterzmust-revalidatezproxy-revalidatezs-maxage�	immutable)
rrXrYrZrjrur�r��must_revalidate�proxy_revalidaterV�s_maxager�r[rrr�r�&s���������*$�
#�H�d�D�
9�
9�F�$�$�Y��T�:�:�G�,�,�->��d�K�K�O�-�-�.@�$��M�M��%�%�j�$��<�<�H�&�&�{�D�$�?�?�I�I�Irr�c�@��t�fd��fd��fd�d�����S)z�Return a new property object for a content security policy header.
    Useful if you want to add support for a csp extension in a
    subclass.
    c�.��|����Sr()�
_get_valuergs �rrzcsp_property.<locals>.<lambda>J����!�,�,�s�#�#�rc�0��|��|��Sr()�
_set_value)r2r#r!s  �rrzcsp_property.<locals>.<lambda>Ks���Q�\�\�#�q�)�)�rc�.��|����Sr()�
_del_valuergs �rrzcsp_property.<locals>.<lambda>Lr�rrhri)r!s`r�csp_propertyr�DsF���
�#�#�#�#�)�)�)�)�#�#�#�#�����	��rc�d�eZdZdZed��Zed��Zed��Zed��Zed��Z	ed��Z
ed��Zed	��Zed
��Z
ed��Zed��Zed
��Zed��Zed��Zed��Zed��Zed��Zed��Zed��Zed��Zed��Zed��Zed��Zed��Zed��Zd$d�Zd�Zd�Z d �Z!d!�Z"d"�Z#d#�Z$dS)%�ContentSecurityPolicyaVSubclass of a dict that stores values for a Content Security Policy
    header. It has accessors for all the level 3 policies.

    Because the csp directives in the HTTP header use dashes the
    python descriptors use underscores for that.

    To get a header of the :class:`ContentSecuirtyPolicy` object again
    you can convert the object into a string or call the
    :meth:`to_header` method.  If you plan to subclass it and add your
    own items have a look at the sourcecode for that class.

    .. versionadded:: 1.0.0
       Support for Content Security Policy headers was added.

    zbase-uriz	child-srczconnect-srczdefault-srczfont-srczform-actionzframe-ancestorsz	frame-srczimg-srczmanifest-srcz	media-srcznavigate-toz
object-srczprefetch-srczplugin-typesz	report-toz
report-uri�sandboxz
script-srczscript-src-attrzscript-src-elemz	style-srczstyle-src-attrzstyle-src-elemz
worker-srcr[Nc�`�t�||pd��||_|du|_dSrnrorps   rrizContentSecurityPolicy.__init__|rqrc�,�|�|��S)rt�r�r5s  rr�z ContentSecurityPolicy._get_value�s���x�x��}�}�rc�D�|�|�|d��dS|||<dSrsrr?s   rr�z ContentSecurityPolicy._set_value�s.���=��H�H�S�$�������D��I�I�Irc��||vr||=dSdSrsr[r5s  rr�z ContentSecurityPolicy._del_value�rxrc�*�tj|��Srz)rH�dump_csp_headerrs rrzContentSecurityPolicy.to_header�s���#�D�)�)�)rc�*�|���Sr(rrs rr�zContentSecurityPolicy.__str__�r rc��d�d�t|�����D����}dt|��j�d|�d�S)Nr~c3�*K�|]\}}|�d|��V��dSr�r[rFs   rr�z1ContentSecurityPolicy.__repr__.<locals>.<genexpr>�r�rr�r�r�r�s  rrbzContentSecurityPolicy.__repr__�r�rr�)%rrXrYrZr��base_uri�	child_src�connect_src�default_src�font_src�form_action�frame_ancestors�	frame_src�img_src�manifest_src�	media_src�navigate_to�
object_src�prefetch_src�plugin_types�	report_to�
report_urir��
script_src�script_src_attr�script_src_elem�	style_src�style_src_attr�style_src_elem�
worker_srcrir�r�r�rr�rbr[rrr�r�Qs
�������� �|�J�'�'�H���[�)�)�I��,�}�-�-�K��,�}�-�-�K��|�J�'�'�H��,�}�-�-�K�"�l�#4�5�5�O���[�)�)�I��l�9�%�%�G��<��/�/�L���[�)�)�I��,�}�-�-�K���l�+�+�J��<��/�/�L��<��/�/�L���[�)�)�I���l�+�+�J��l�9�%�%�G���l�+�+�J�"�l�#4�5�5�O�"�l�#4�5�5�O���[�)�)�I�!�\�"2�3�3�N�!�\�"2�3�3�N���l�+�+�J�+�+�+�+�
���������
*�*�*� � � �3�3�3�3�3rr�c� �eZdZdZdd�Zd�ZdS)�CallbackDictzwA dict that calls a function passed every time something is changed.
    The function is passed the dict instance.
    Nc�N�t�||pd��||_dSrn�rrir�)r�initialr�s   rrizCallbackDict.__init__�s%���
�
�d�G�M�r�*�*�*�"����rc�h�dt|��j�dt�|���d�S�Nr�r~r�r�rs rrbzCallbackDict.__repr__�s0��?�4��:�:�&�?�?����t�)<�)<�?�?�?�?rr�)rrXrYrZrirbr[rrr�r��sF��������#�#�#�#�@�@�@�@�@rr�c��eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zdd�Zd
�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS)�	HeaderSeta�Similar to the :class:`ETags` class this implements a set-like structure.
    Unlike :class:`ETags` this is case insensitive and used for vary, allow, and
    content-language headers.

    If not constructed using the :func:`parse_set_header` function the
    instantiation works like this:

    >>> hs = HeaderSet(['foo', 'bar', 'baz'])
    >>> hs
    HeaderSet(['foo', 'bar', 'baz'])
    Nc�l�t|pd��|_d�|jD��|_||_dS)Nr[c�6�h|]}|�����Sr[r^r1s  r�	<setcomp>z%HeaderSet.__init__.<locals>.<setcomp>�s ��6�6�6�1�Q�W�W�Y�Y�6�6�6r)r�_headers�_setr�)r�headersr�s   rrizHeaderSet.__init__�s7���W�]��+�+��
�6�6��
�6�6�6��	�"����rc�2�|�|f��dS)zAdd a new header to the set.N)r~�r�headers  rr�z
HeaderSet.add�s�����V�I�����rc�F�|���}||jvrt|���|j�|��t	|j��D]'\}}|���|kr
|j|=n�(|j�|�|��dSdS)aCRemove a header from the set.  This raises an :exc:`KeyError` if the
        header is not in the set.

        .. versionchanged:: 0.5
            In older versions a :exc:`IndexError` was raised instead of a
            :exc:`KeyError` if the object was missing.

        :param header: the header to be removed.
        N)rXr�r�rFr�r�r�)rr�r!r�s    rrFzHeaderSet.remove�s����l�l�n�n���d�i����6�"�"�"��	�������!�$�-�0�0�	�	�H�C���y�y�{�{�f�$�$��M�#�&���%��>�%��N�N�4� � � � � �&�%rc��d}|D]U}|���}||jvr6|j�|��|j�|��d}�V|r|j�|�|��dSdSdS)z�Add all the headers from the iterable to the set.

        :param iterable: updates the set with the items from the iterable.
        FTN)rXr�r�rDr�r�)rrH�inserted_anyr�r!s     rr~zHeaderSet.update�s���
���	$�	$�F��,�,�.�.�C��$�)�#�#��
�$�$�V�,�,�,��	�
�
�c�"�"�"�#����	!�D�N�6��N�N�4� � � � � �	!�	!�6�6rc�T�	|�|��dS#t$rYdSwxYw)zdLike :meth:`remove` but ignores errors.

        :param header: the header to be discarded.
        N)rFr�r�s  r�discardzHeaderSet.discard�sA��
	��K�K���������	�	�	��D�D�	���s��
'�'c��|���}t|j��D]!\}}|���|kr|cS�"dS)z�Return the index of the header in the set or return -1 if not found.

        :param header: the header to be looked up.
        rN)rXr�r�)rr�r�rCs    rrzHeaderSet.find�sT��
������"�4�=�1�1�	�	�I�C���z�z�|�|�v�%�%��
�
�
�&��rrc�Z�|�|��}|dkrt|���|S)z�Return the index of the header in the set or raise an
        :exc:`IndexError`.

        :param header: the header to be looked up.
        r)r�
IndexError)rr�r,s   rrPzHeaderSet.index�s1���Y�Y�v�
�
��
��6�6��V�$�$�$��	rc��|j���|jdd�=|j�|�|��dSdS)zClear the set.N)r�r�r�r�rs rr�zHeaderSet.clear	sJ���	�������M�!�!�!���>�%��N�N�4� � � � � �&�%rFc�V�|rt|j��St|j��S)a�Return the set as real python set type.  When calling this, all
        the items are converted to lowercase and the ordering is lost.

        :param preserve_casing: if set to `True` the items in the set returned
                                will have the original case like in the
                                :class:`HeaderSet`, otherwise they will
                                be lowercase.
        )r&r�r�)r�preserve_casings  r�as_setzHeaderSet.as_set	s*���	&��t�}�%�%�%��4�9�~�~�rc�f�d�ttj|j����S)rr)r�r`rH�quote_header_valuer�rs rrzHeaderSet.to_header	s#���y�y��T�4�d�m�D�D�E�E�Erc��|j|Sr()r�)rr�s  rr�zHeaderSet.__getitem__	s���}�S�!�!rc���|j�|��}|j�|�����|j�|�|��dSdSr()r�rQr�rFrXr�)rr�r,s   rr6zHeaderSet.__delitem__	s]��
�]�
�
�s�
#�
#���	��������$�$�$��>�%��N�N�4� � � � � �&�%rc� �|j|}|j�|�����||j|<|j�|�����|j�|�|��dSdSr()r�r�rFrXr�r�)rr�r"�olds    rr@zHeaderSet.__setitem__%	s|���m�C� ���	��������%�%�%�"��
�c���	�
�
�e�k�k�m�m�$�$�$��>�%��N�N�4� � � � � �&�%rc�8�|���|jvSr()rXr�r�s  rrvzHeaderSet.__contains__-	s���|�|�~�~���*�*rc�*�t|j��Sr()r�r�rs rryzHeaderSet.__len__0	s���4�9�~�~�rc�*�t|j��Sr()rr�rs rr�zHeaderSet.__iter__3	����D�M�"�"�"rc�*�t|j��Sr()rur�rs r�__bool__zHeaderSet.__bool__6	s���D�I���rc�*�|���Sr(rrs rr�zHeaderSet.__str__9	r rc�@�t|��j�d|j�d�Sr_)rrr�rs rrbzHeaderSet.__repr__<	s$���t�*�*�%�:�:��
�:�:�:�:rr�r�)rrXrYrZrir�rFr~r�rrPr�r�rr�r6r@rvryr�r�r�rbr[rrr�r��sH������
�
�#�#�#�#�
���!�!�!�*
!�
!�
!����	�	�	�	�	�	�!�!�!�����F�F�F�"�"�"�!�!�!�!�!�!�+�+�+����#�#�#���� � � �;�;�;�;�;rr�c�r�eZdZdZdd�Zdd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zdd�Zd
�Z
d�Zd�Zd�Zd�Zd�ZdS)�ETagszYA set that can be used to check if one etag is present in a collection
    of etags.
    NFc��|s|rt|��|_nt��|_t|pd��|_||_dSrn)ru�_strong�_weak�star_tag)r�strong_etags�
weak_etagsr�s    rrizETags.__init__E	sL���	'�L�	'�$�\�2�2�D�L�L�$�;�;�D�L��z�/�R�0�0��
� ��
�
�
rc�f�t|j��}|r|�|j��|S)zoConvert the `ETags` object into a python set.  Per default all the
        weak etags are not part of this set.)r&r�r~r�)r�include_weakr,s   rr�zETags.as_setN	s4�����
�
���	"��I�I�d�j�!�!�!��	rc��||jvS)zCheck if an etag is weak.)r��r�etags  r�is_weakz
ETags.is_weakV	s���t�z�!�!rc��||jvS)zCheck if an etag is strong.)r�rs  r�	is_strongzETags.is_strongZ	s���t�|�#�#rc�V�|�|��p|�|��S)zCCheck if an etag is part of the set including weak and strong tags.)r�containsrs  r�
contains_weakzETags.contains_weak^	s%���|�|�D�!�!�8�T�]�]�4�%8�%8�8rc�>�|jrdS|�|��S)zxCheck if an etag is part of the set ignoring weak tags.
        It is also possible to use the ``in`` operator.
        T)r�rrs  rrzETags.containsb	s%���=�	��4��~�~�d�#�#�#rc��tj|��\}}|r|�|��S|�|��S)z�When passed a quoted tag it will check if this tag is part of the
        set.  If the tag is weak it is checked against weak and strong tags,
        otherwise strong only.)rH�unquote_etagr	r)rr�weaks   r�contains_rawzETags.contains_rawj	sF���&�t�,�,�
��d��	,��%�%�d�+�+�+��}�}�T�"�"�"rc��|jrdSd�d�|jD��d�|jD��z��S)z0Convert the etags set into a HTTP header string.rrc��g|]}d|�d���	S)�"r[r1s  rr3z#ETags.to_header.<locals>.<listcomp>x	s ��,�,�,�!�X��X�X�X�,�,�,rc��g|]}d|�d���	S)zW/"rr[r1s  rr3z#ETags.to_header.<locals>.<listcomp>x	s ��/O�/O�/O�q�
�a�
�
�
�/O�/O�/Or)r�r�r�r�rs rrzETags.to_headers	sP���=�	��3��y�y�,�,�t�|�,�,�,�/O�/O�D�J�/O�/O�/O�O�
�
�	
rc��||g�d��dkrtd���|�tj|��}|r||jvrdS||jvS)Nr
z-either tag or data required, but at least oneT)�countrrH�
generate_etagr�r�)rr�datars    r�__call__zETags.__call__{	sj���$�<���d�#�#�q�(�(��K�L�L�L��<��%�d�+�+�D��	��t�z�!�!��t��t�|�#�#rc�F�t|jp
|jp|j��Sr()rur�r�r�rs rr�zETags.__bool__�	s ���D�M�?�T�\�?�T�Z�@�@�@rc�*�|���Sr(rrs rr�z
ETags.__str__�	r rc�*�t|j��Sr()r�r�rs rryz
ETags.__len__�	s���4�<� � � rc�*�t|j��Sr()rr�rs rr�zETags.__iter__�	s���D�L�!�!�!rc�,�|�|��Sr()rrs  rrvzETags.__contains__�	s���}�}�T�"�"�"rc�R�dt|��j�dt|���d�Sr��rrrNrs rrbzETags.__repr__�	�*��7�4��:�:�&�7�7��T���7�7�7�7rr�r�)rrXrYrZrir�rrr	rrrrr�r�ryr�rvrbr[rrr�r�@	s��������!�!�!�!�����"�"�"�$�$�$�9�9�9�$�$�$�#�#�#�
�
�
�$�$�$�$�A�A�A� � � �!�!�!�"�"�"�#�#�#�8�8�8�8�8rr�c�,�eZdZdZdd�Zd�Zd�Zd�ZdS)�IfRangez�Very simple object that represents the `If-Range` header in parsed
    form.  It will either have neither a etag or date or one of either but
    never both.

    .. versionadded:: 0.7
    Nc�"�||_||_dSr()r�date)rrr#s   rrizIfRange.__init__�	s����	���	�	�	rc��|j�tj|j��S|j�tj|j��SdS)�-Converts the object back into an HTTP header.N�)r#rH�	http_dater�
quote_etagrs rrzIfRange.to_header�	s;���9� ��>�$�)�,�,�,��9� ��?�4�9�-�-�-��rrc�*�|���Sr(rrs rr�zIfRange.__str__�	r rc�R�dt|��j�dt|���d�Sr�rrs rrbzIfRange.__repr__�	rrr�)rrXrYrZrirr�rbr[rrr!r!�	s_��������������� � � �8�8�8�8�8rr!c�<�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	S)
�RangeaXRepresents a ``Range`` header. All methods only support only
    bytes as the unit. Stores a list of ranges if given, but the methods
    only work if only one range is provided.

    :raise ValueError: If the ranges provided are invalid.

    .. versionchanged:: 0.15
        The ranges passed in are validated.

    .. versionadded:: 0.7
    c�z�||_||_|D])\}}|�|� |dks||krt||f�d�����*dS)Nrz is not a valid range.)�units�rangesr�)rr.r/�start�ends     rrizRange.__init__�	sh����
���� �	J�	J�J�E�3��}���e�a�i�i�5�C�<�<� �U�C�L�!H�!H�!H�I�I�I��	J�	Jrc���|jdks|�t|j��dkrdS|jd\}}|�
|}|dkr||z
}tj|||��r|t||��fSdS)z�If the range is for bytes, the length is not None and there is
        exactly one range and it is satisfiable it returns a ``(start, stop)``
        tuple, otherwise `None`.
        rLNr
r)r.r�r/rH�is_byte_range_valid�min)r�lengthr0r1s    r�range_for_lengthzRange.range_for_length�	s���
�:�� � �F�N�c�$�+�6F�6F�!�6K�6K��4��[��^�
��s��;��C��q�y�y������#�E�3��7�7�	+��#�c�6�*�*�*�*��trc�z�|�|��}|�#t|j|d|d|��SdS)z�Creates a :class:`~werkzeug.datastructures.ContentRange` object
        from the current range and given content length.
        Nrr
)r6�ContentRanger.)rr5�rngs   r�make_content_rangezRange.make_content_range�	s?���#�#�F�+�+���?���
�C��F�C��F�F�C�C�C��trc��g}|jD]R\}}|�.|�|dkr|�d�nt|�����5|�|�d|dz
�����S|j�dd�|����S)r%NrrDr
r�r)r/rDrNr.r�)rr/�beginr1s    rrzRange.to_header�	s������+�	4�	4�J�E�3��{��
�
�U�a�Z�Z��k�k�k�k�S��Z�Z�H�H�H�H��
�
��2�2��q��2�2�3�3�3�3��*�1�1�s�x�x��/�/�1�1�1rc�v�|�|��}|�!|j�d|d�d|ddz
�d|��SdS)z\Converts the object into `Content-Range` HTTP header,
        based on given length
        Nr~rrDr
r8)r6r.)rr5�ranges   r�to_content_range_headerzRange.to_content_range_header�	sT���%�%�f�-�-�����j�E�E�5��8�E�E�e�A�h��l�E�E�V�E�E�E��trc�*�|���Sr(rrs rr�z
Range.__str__�	r rc�R�dt|��j�dt|���d�Sr�rrs rrbzRange.__repr__�	rrN)rrXrYrZrir6r:rr?r�rbr[rrr,r,�	s�������
�
�	J�	J�	J���� ���2�2�2���� � � �8�8�8�8�8rr,c�8���fd�}�fd�}t||��S)Nc�$��t|���Sr()r�rhs �r�fgetz _callback_property.<locals>.fget
s����t�T�"�"�"rc�f��t|�|��|j�|�|��dSdSr()�setattrr��rr"r�s  �r�fsetz _callback_property.<locals>.fset
s=�����d�E�"�"�"��>�%��N�N�4� � � � � �&�%rri)r�rDrHs`  r�_callback_propertyrI
sG���#�#�#�#�#�!�!�!�!�!�
�D�$���rc��eZdZdZdd�Zed��Zed��Zed��Zed��Z	dd	�Z
d
�Zd�Zd�Z
d
�Zd�ZdS)r8zDRepresents the content range header.

    .. versionadded:: 0.7
    Nc��tj|||��s
Jd���||_|�||||��dS)N�Bad range provided)rHr3r�r&)rr.r0�stopr5r�s      rrizContentRange.__init__
sK���'��t�V�<�<�R�R�>R�R�R�R�"��������f�e�,�,�,�,�,r�_units�_start�_stop�_lengthrLc��tj|||��s
Jd���||_||_||_||_|j�|�|��dSdS)z#Simple method to update the ranges.rLN)rHr3rNrOrPrQr�)rr0rMr5r.s     rr&zContentRange.set"
sj���'��t�V�<�<�R�R�>R�R�R�R���������
�����>�%��N�N�4� � � � � �&�%rc�6�|�ddd���dS)zcSets the units to `None` which indicates that the header should
        no longer be used.
        N�r.r�rs r�unsetzContentRange.unset,
s"��	
����t�4��(�(�(�(�(rc��|j�dS|j�d}n|j}|j�|j�d|��S|j�d|j�d|jdz
�d|��S)Nr&rz */r~rDr
r8)r.r5r0rM)rr5s  rrzContentRange.to_header2
sq���:���2��;���F�F��[�F��:���j�-�-�V�-�-�-��*�D�D�t�z�D�D�D�I��M�D�D�F�D�D�Drc��|jduSr(rTrs rr�zContentRange.__bool__=
s���z��%�%rc�*�|���Sr(rrs rr�zContentRange.__str__@
r rc�R�dt|��j�dt|���d�Sr�rrs rrbzContentRange.__repr__C
rrr�)NrL)rrXrYrZrirIr.r0rMr5r&rUrr�r�rbr[rrr8r8
s���������
-�-�-�-�
��x�(�(�E���x�(�(�E���g�&�&�D�
�
�	�
*�
*�F�!�!�!�!�)�)�)�	E�	E�	E�&�&�&� � � �8�8�8�8�8rr8c��eZdZdZdd�Zed���Zed���Zed���Zed���Z	ed���Z
ed	���Zed
���Zed���Z
ed���Zed
���Zd�ZdS)�
Authorizationa=Represents an ``Authorization`` header sent by the client.

    This is returned by
    :func:`~werkzeug.http.parse_authorization_header`. It can be useful
    to create the object manually to pass to the test
    :class:`~werkzeug.test.Client`.

    .. versionchanged:: 0.5
        This object became immutable.
    Nc�N�t�||pi��||_dSr()rrir)r�	auth_typers   rrizAuthorization.__init__S
s%���
�
�d�D�J�B�'�'�'���	�	�	rc�,�|�d��S)zdThe username transmitted.  This is set for both basic and digest
        auth all the time.
        �usernamer�rs rr_zAuthorization.usernameW
���
�x�x�
�#�#�#rc�,�|�d��S)zsWhen the authentication type is basic this is the password
        transmitted by the client, else `None`.
        �passwordr�rs rrbzAuthorization.password^
r`rc�,�|�d��S)z8This is the server realm sent back for HTTP digest auth.�realmr�rs rrdzAuthorization.realme
s���x�x�� � � rc�,�|�d��S)z�The nonce the server sent for digest auth, sent back by the client.
        A nonce should be unique for every 401 response for HTTP digest auth.
        �noncer�rs rrfzAuthorization.noncej
s��
�x�x�� � � rc�,�|�d��S)z�The URI from Request-URI of the Request-Line; duplicated because
        proxies are allowed to change the Request-Line in transit.  HTTP
        digest auth only.
        �urir�rs rrhzAuthorization.uriq
����x�x����rc�,�|�d��S)zzThe nonce count value transmitted by clients if a qop-header is
        also transmitted.  HTTP digest auth only.
        �ncr�rs rrkzAuthorization.ncy
s��
�x�x��~�~�rc�,�|�d��S)z�If the server sent a qop-header in the ``WWW-Authenticate``
        header, the client has to provide this value for HTTP digest auth.
        See the RFC for more details.
        �cnoncer�rs rrmzAuthorization.cnonce�
����x�x��!�!�!rc�,�|�d��S)z�A string of 32 hex digits computed as defined in RFC 2617, which
        proves that the user knows a password.  Digest auth only.
        �responser�rs rrpzAuthorization.response�
r`rc�,�|�d��S)z�The opaque header from the server returned unchanged by the client.
        It is recommended that this string be base64 or hexadecimal data.
        Digest auth only.
        �opaquer�rs rrrzAuthorization.opaque�
rnrc�,�|�d��S)z�Indicates what "quality of protection" the client has applied to
        the message for HTTP digest auth. Note that this is a single token,
        not a quoted list of alternatives as in WWW-Authenticate.
        �qopr�rs rrtzAuthorization.qop�
rirc�&�|jdkrMtj|j�d|j��������d��}d|��S|jdkrdtj|����Std|j�d����)	z�Convert to a string value for an ``Authorization`` header.

        .. versionadded:: 2.0
            Added to support passing authorization to the test client.
        �basic�:�utf8zBasic �digestzDigest zUnsupported type �.)
r�base64�	b64encoder_rbrdrMrHr{r�r�s  rrzAuthorization.to_header�
s����9�����$��=�2�2�4�=�2�2�9�9�;�;����f�V�n�n�
�$�E�#�#�#��9�� � �5�T�-�d�3�3�5�5�5��;�T�Y�;�;�;�<�<�<rr()rrXrYrZrir.r_rbrdrfrhrkrmrprrrtrr[rrr[r[G
sO������	�	������$�$��X�$��$�$��X�$��!�!��X�!��!�!��X�!�����X������X���"�"��X�"��$�$��X�$��"�"��X�"�����X��=�=�=�=�=rr[c�8���fd�}t�fd�||���S)alA static helper function for Authentication subclasses to add
    extra authentication system properties onto a class::

        class FooAuthenticate(WWWAuthenticate):
            special_realm = auth_property('special_realm')

    For more information have a look at the sourcecode to see how the
    regular properties (:attr:`realm` etc.) are implemented.
    c�`��|�|��d��dSt|��|�<dSr()rQrNrGs  �rr�z!auth_property.<locals>._set_value�
s5����=��H�H�T�4� � � � � ��U���D��J�J�Jrc�.��|����Sr(r�)r2r�s �rrzauth_property.<locals>.<lambda>�
s���a�e�e�D�k�k�r��docri)r�r�r�s`  r�
auth_propertyr��
s=���$�$�$�$�$��)�)�)�)�:�3�?�?�?�?rc�0���fd�}t||���S)Nc�b�����fd�}tj�����|��S)Nc�T��|s	��vr��=dS|r|�����<dSdSr(r)�
header_setr�rs ��rr�z._set_property.<locals>.fget.<locals>.on_update�
sI����
4�$�$�,�,���J�J�J��
4�'�1�1�3�3��T�
�
�
�
4�
4r)rH�parse_set_headerr�)rr�r�s` �rrDz_set_property.<locals>.fget�
sA����	4�	4�	4�	4�	4�	4��$�T�X�X�d�^�^�Y�?�?�?rr�ri)r�r�rDs`  r�
_set_propertyr��
s6���@�@�@�@�@��D�c�"�"�"�"rc�Z�eZdZdZegd���Zdd�Zdd�Z	d d	�Zd
�Z	d�Z
d�Zed
d���Z
edd���Zedd���Zedd���Zedd���Zedd���Zedd���Zed���Zejd���Zee��ZdS)!�WWWAuthenticatez5Provides simple access to `WWW-Authenticate` headers.)�domainrfrrrdrtNc�\�t�||pd��|r||d<||_dS)Nr[�
__auth_type__r�)rr]r�r�s    rrizWWWAuthenticate.__init__�
s7���
�
�d�F�L�b�)�)�)��	.�$-�D��!�"����r�authentication requiredc��t�|��t�|d|d���|jr|�|��dSdS)z*Clear the auth info and enable basic auth.rv)r�rdN)rr�r~r�)rrds  r�	set_basiczWWWAuthenticate.set_basic�
s\���
�
�4�������D�G�e�D�D�E�E�E��>�	!��N�N�4� � � � � �	!�	!r��authFc��d||tj|��d�}|rd|d<|�||d<|�||d<t�|��t�||��|jr|�|��dSdS)z+Clear the auth info and enable digest auth.ry)r�rdrfrt�TRUE�staleNrr�	algorithm)rHr{rr�r~r�)rrdrfrtrrr�r�r�s        r�
set_digestzWWWAuthenticate.set_digest�
s���
&����#�C�(�(�	
�
���	 ��A�g�J��� �A�h�K�� �&�A�k�N��
�
�4�������D�!�����>�	!��N�N�4� � � � � �	!�	!rc���t���}|�dd��pd}�fd�|���D��}d�d�|D����}|����d|��S)z9Convert the stored values into a WWW-Authenticate header.r�Nrvc3�\�K�|]&\}}|tj||�jv���fV��'dS))�allow_tokenN)rHr��_require_quoting)r�r�r#rs   �rr�z,WWWAuthenticate.to_header.<locals>.<genexpr>�
sX�����
�
���1���'��q��@U�7U�V�V�V�W�
�
�
�
�
�
rrc�"�g|]\}}|�d|����
S)r�r[rFs   rr3z-WWWAuthenticate.to_header.<locals>.<listcomp>s&��?�?�?�d�a��!�z�z�a�z�z�?�?�?rr~)rrQrr�r�)rr�r]�kv_items�	kv_strings`    rrzWWWAuthenticate.to_header�
s������J�J���E�E�/�4�0�0�;�G�	�
�
�
�
����	�	�
�
�
���I�I�?�?�h�?�?�?�@�@�	��/�/�#�#�1�1�i�1�1�1rc�*�|���Sr(rrs rr�zWWWAuthenticate.__str__r rc�\�dt|��j�d|����d�Sr�)rrrrs rrbzWWWAuthenticate.__repr__s.��>�4��:�:�&�>�>����)9�)9�>�>�>�>rr�zZThe type of the auth mechanism. HTTP currently specifies
        ``Basic`` and ``Digest``.r�rdaA string to be displayed to users so they know which
        username and password to use. This string should contain at
        least the name of the host performing the authentication and
        might additionally indicate the collection of users who might
        have access.r�z�A list of URIs that define the protection space. If a URI
        is an absolute path, it is relative to the canonical root URL of
        the server being accessed.rfz�
        A server-specified data string which should be uniquely generated
        each time a 401 response is made. It is recommended that this
        string be base64 or hexadecimal data.rraA string of data, specified by the server, which should
        be returned by the client unchanged in the Authorization header
        of subsequent requests with URIs in the same protection space.
        It is recommended that this string be base64 or hexadecimal
        data.r�a A string indicating a pair of algorithms used to produce
        the digest and a checksum. If this is not present it is assumed
        to be "MD5". If the algorithm is not understood, the challenge
        should be ignored (and a different one used, if there is more
        than one).rtzIA set of quality-of-privacy directives such as auth and
        auth-int.c�d�|�d��}|�|���dkSdS)z}A flag, indicating that the previous request from the client
        was rejected because the nonce value was stale.
        r�N�true)r�rX)r�vals  rr�zWWWAuthenticate.stale;s4��
�h�h�w�����?��9�9�;�;�&�(�(��?rc�L�|�|�dd��dS|rdnd|d<dS)Nr�r��FALSErr�s  rr�zWWWAuthenticate.staleDs7���=��H�H�W�d�#�#�#�#�#�&+�8�F�F��D��M�M�Mr)NNN)r�)r�NNF)rrXrYrZrur�rir�r�rr�rbr�rrdr�r�rfrrr�rtr.r��setterr�r[rrr�r��
s�������?�?�!�y�!N�!N�!N�O�O��#�#�#�#�!�!�!�!�OT�!�!�!�!�*	2�	2�	2� � � �?�?�?��=��
%����D�

�M��
�
�
�
�E��]��
&����F�
�M��
1�
�
�
�E��]��
����F��
��
����I��-�
�
����C��)�)��X�)��\�9�9��\�9�!�L��/�/�M�M�Mrr�c��eZdZdZ						dd�Zd�Zed���Zed���Zed���Z	ed���Z
dd
�Zd�Zd�Z
d
�Zd�Zd�ZdS)r�a@The :class:`FileStorage` class is a thin wrapper over incoming files.
    It is used by the request object to represent uploaded files.  All the
    attributes of the wrapper stream are proxied by the file storage so
    it's possible to do ``storage.read()`` instead of the long form
    ``storage.stream.read()``.
    Nc�h�||_|p
t��|_|�Dt|dd��}|�t	j|��}|r|ddkr|ddkrd}nt	j|��}||_|�t��}||_|�||d<|�t|��|d<dSdS)Nr�rr�rNr�zContent-TypezContent-Length)
r�r�streamr��os�fsdecoder�rQr�rN)rr�r�r�r��content_lengthr�s       rrizFileStorage.__init__Vs�����	��)��	�	���
���v�v�t�4�4�H��#��;�x�0�0���
 �H�Q�K�3�.�.�8�B�<�3�3F�3F�����{�8�,�,�H� ��
��?��i�i�G�����#�&2�G�N�#��%�(+�N�(;�(;�G�$�%�%�%�&�%rc�f�t|d��s tj|j��|_dSdS)N�_parsed_content_type)�hasattrrH�parse_options_headerr�r�rs r�_parse_content_typezFileStorage._parse_content_typezs>���t�3�4�4�	U�(,�(A�$�BS�(T�(T�D�%�%�%�	U�	Urc�6�|j�d��S)z;The content-type sent in the header.  Usually not availablezcontent-type)r�r�rs rr�zFileStorage.content_type~s���|����/�/�/rc�x�	t|j�d��pd��S#t$rYdSwxYw)z=The content-length sent in the header.  Usually not availablezcontent-lengthr)rVr�r�r�rs rr�zFileStorage.content_length�sM��	��t�|�'�'�(8�9�9�>�Q�?�?�?���	�	�	��1�1�	���s�(+�
9�9c�h�|���|jd���S)aLike :attr:`content_type`, but without parameters (eg, without
        charset, type etc.) and always lowercase.  For example if the content
        type is ``text/HTML; charset=utf-8`` the mimetype would be
        ``'text/html'``.

        .. versionadded:: 0.7
        r)r�r�rXrs r�mimetypezFileStorage.mimetype�s0��	
� � �"�"�"��(��+�1�1�3�3�3rc�D�|���|jdS)z�The mimetype parameters as dict.  For example if the content
        type is ``text/html; charset=utf-8`` the params would be
        ``{'charset': 'utf-8'}``.

        .. versionadded:: 0.7
        r
)r�r�rs r�mimetype_paramszFileStorage.mimetype_params�s$��	
� � �"�"�"��(��+�+r�@c�0�ddlm}d}t|d��rt|��}t	|t
��rt
|d��}d}	||j||��|r|���dSdS#|r|���wwxYw)anSave the file to a destination path or file object.  If the
        destination is a file object you have to close it yourself after the
        call.  The buffer size is the number of bytes held in memory during
        the copy process.  It defaults to 16KB.

        For secure file saving also have a look at :func:`secure_filename`.

        :param dst: a filename, :class:`os.PathLike`, or open file
            object to write to.
        :param buffer_size: Passed as the ``length`` parameter of
            :func:`shutil.copyfileobj`.

        .. versionchanged:: 1.0
            Supports :mod:`pathlib`.
        r)�copyfileobjF�
__fspath__�wbTN)	�shutilr�r�r	rrNr�r��close)r�dst�buffer_sizer��	close_dsts     r�savezFileStorage.save�s��� 	'�&�&�&�&�&��	��3��%�%�	���+�+�C��c�3���	��s�D�/�/�C��I�	��K���S�+�6�6�6��
��	�	������
�
��y�
��	�	�����
���s�A<�<Bc�\�	|j���dS#t$rYdSwxYw)z&Close the underlying file if possible.N)r�r��	Exceptionrs rr�zFileStorage.close�sC��	��K����������	�	�	��D�D�	���s��
+�+c�*�t|j��Sr()rur�rs rr�zFileStorage.__bool__�r�rc��	t|j|��S#t$r3t|jd��rt|jj|��cYS�wxYw)N�_file)r�r��AttributeErrorr�r�rhs  r�__getattr__zFileStorage.__getattr__�sh��	��4�;��-�-�-���	�	�	��t�{�G�,�,�
8��t�{�0�$�7�7�7�7�7��
	���s��9A�Ac�*�t|j��Sr()rr�rs rr�zFileStorage.__iter__�s���D�K� � � rc�R�dt|��j�d|j�d|j�d�S)Nr�r�z (z)>)rrr�r�rs rrbzFileStorage.__repr__�s1��T�4��:�:�&�T�T�$�-�T�T�T�=N�T�T�T�Tr)NNNNNN)r�)rrXrYrZrir�r.r�r�r�r�r�r�r�r�r�rbr[rrr�r�Ns*����������
����"<�"<�"<�"<�HU�U�U��0�0��X�0�����X���	4�	4��X�	4��,�,��X�,�����B���#�#�#�	�	�	�!�!�!�U�U�U�U�Urr�)rHr()Hr{r[r�r��re�collections.abcrrr�r�ior�	itertoolsrr	r&r�	_internalrrr$r&rr]rer�r�rr�r�r�rr�rrJrOrQr�r�r�r�r�r�r�r��compiler0r2r4rJrKrMrXrjrlr�r�r�r�r�r�r�r!r,rIr8r[r�r�r�r�rHr[rr�<module>r�sW��
�
�
�
�
�
�
�
�����	�	�	�	�	�	�	�	�&�&�&�&�&�&�&�&�&�&�&�&�������������������������������������F�F�F����"2�2�2�2�2�2�2�2�j	?�	?�	?�	?�	?�&��	?�	?�	?�/�/�/�/�/�/�/�/�d�����0����<
�
�
�%�%�%�%�%�d�%�%�%�D&�&�&�&�&��&�&�&�R�����"4�6H����$IJ�IJ�IJ�IJ�IJ�"�IJ�IJ�IJ�X
)�)�)�)�)�)�)�)�@r/�r/�r/�r/�r/�y�r/�r/�r/�j������B8�B8�B8�B8�B8�B8�B8�B8�J2�2�2�2�2�2�2�2�j0I�0I�0I�0I�0I�*�G�0I�0I�0I�fC8�C8�C8�C8�C8�/��C8�C8�C8�L�����I����B�����&�����(�����0�)����"����� 7�9I����(i�i�i�i�i�]�i�i�i�X���,�-�-��/�/�/�?*�?*�?*�?*�?*��?*�?*�?*�D�2�:�g�&�&��1�1�1�
3�3�3�3�3�V�3�3�3�l
D�
D�
D�
D�
D�F�
D�
D�
D����`:�`:�`:�`:�`:�O�T�`:�`:�`:�FJ�J�J�J�J�,�m�J�J�J�.@�@�@�@�@�=�@�@�@�<
�
�
�I3�I3�I3�I3�I3�O�T�I3�I3�I3�X
@�
@�
@�
@�
@�?�D�
@�
@�
@�S;�S;�S;�S;�S;�
�S;�S;�S;�lU8�U8�U8�U8�U8�J�U8�U8�U8�p8�8�8�8�8�8�8�8�<H8�H8�H8�H8�H8�H8�H8�H8�V	 �	 �	 �78�78�78�78�78�78�78�78�tg=�g=�g=�g=�g=�&��g=�g=�g=�T@�@�@�@�(
#�
#�
#�
#�y0�y0�y0�y0�y0�o�t�y0�y0�y0�xNU�NU�NU�NU�NU�NU�NU�NU�d�������r

Youez - 2016 - github.com/yon3zu
LinuXploit