%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/web/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/web/__pycache__/http_headers.cpython-312.pyc

�

Ϫ�fs#���dZddlmZddlmZmZmZmZm	Z	m
Z
mZmZmZm
Z
mZddlmZmZed�Zdedefd�Zd	edefd
�ZeGd�d��ZdgZy
)z2
An API for storing HTTP header names and values.
�)�Sequence)�AnyStr�Dict�Iterator�List�Mapping�Optionalr�Tuple�TypeVar�Union�overload)�cmp�
comparable�_T�name�returnc��dj|jd�D�cgc]}|j���c}�Scc}w)z�
    Return a byte string which is capitalized using '-' as a word separator.

    @param name: The name of the header to capitalize.

    @return: The given header capitalized using '-' as a word separator.
    �-)�join�split�
capitalize)r�words  �:/usr/lib/python3/dist-packages/twisted/web/http_headers.py�_dashCapitalizers1���9�9�D�J�J�t�4D�E�D�d�o�o�'�E�F�F��Es�=�headerComponentc�@�dj|j��S)z�
    Replace linear whitespace (C{\n}, C{\r\n}, C{\r}) in a header key
    or value with a single space.

    @param headerComponent: The header key or value to sanitize.

    @return: The sanitized header key or value.
    � )r�
splitlines)rs r�_sanitizeLinearWhitespacer(s���9�9�_�/�/�1�2�2�c
�4�eZdZdZdddddddd	�Z	d"deeeeefdd
fd
�Z	de
fd�Zd�Zde
e
efdefd�Zd�Zdedefd�Zdedd
fd�Zede
e
efdeedd
fd��Zede
e
efdee
dd
fd��Zede
e
efdee
e
efdd
fd��Zde
e
efdedd
fd�Zde
e
efde
e
efdd
fd�Zededeeefd��Zededede
eeeffd��Z	d"dedeede
eeeeffd�Zdeeeeeffd �Zdedefd!�Zy
)#�Headersa@
    Stores HTTP headers in a key and multiple value format.

    When passed L{str}, header names (e.g. 'Content-Type')
    are encoded using ISO-8859-1 and header values (e.g.
    'text/html;charset=utf-8') are encoded using UTF-8. Some methods that return
    values will return them in the same type as the name given.

    If the header keys or values cannot be encoded or decoded using the rules
    above, using just L{bytes} arguments to the methods of this class will
    ensure no decoding or encoding is done, and L{Headers} will treat the keys
    and values as opaque byte strings.

    @cvar _caseMappings: A L{dict} that maps lowercase header names
        to their canonicalized representation.

    @ivar _rawHeaders: A L{dict} mapping header names as L{bytes} to L{list}s of
        header values as L{bytes}.
    sContent-MD5sDNTsETagsP3PsTEsWWW-AuthenticatesX-XSS-Protection)scontent-md5sdntsetagsp3psteswww-authenticatesx-xss-protectionN�
rawHeadersrc�l�i|_|�+|j�D]\}}|j||��yy�N)�_rawHeaders�items�
setRawHeaders)�selfr#r�valuess    r�__init__zHeaders.__init__TsC��68����!� *� 0� 0� 2�
1���f��"�"�4��0�
1�"r c�b�dj|jj|j�S)zR
        Return a string fully describing the headers set on this object.
        z{}({!r}))�format�	__class__�__name__r&�r)s r�__repr__zHeaders.__repr__]s-��� � ��N�N�#�#����
�	
r c���t|t�rNtt|jj��t|jj���StS)zu
        Define L{Headers} instances as being equal to each other if they have
        the same raw headers.
        )�
isinstancer"r�sortedr&r'�NotImplemented)r)�others  r�__cmp__zHeaders.__cmp__fsP��
�e�W�%���t�'�'�-�-�/�0�&��9J�9J�9P�9P�9R�2S��
��r rc��t|t�r|j�jd�S|j�S)z�
        Encode the name of a header (eg 'Content-Type') to an ISO-8859-1 encoded
        bytestring if required.

        @param name: A HTTP header name

        @return: C{name}, encoded if required, lowercased
        z
iso-8859-1)r3�str�lower�encode�r)rs  r�_encodeNamezHeaders._encodeNameqs1���d�C� ��:�:�<�&�&�|�4�4��z�z�|�r c�8�|j|j�S)zg
        Return a copy of itself with the same headers set.

        @return: A new L{Headers}
        )r.r&r0s r�copyzHeaders.copy~s���~�~�d�.�.�/�/r c�<�|j|�|jvS)z�
        Check for the existence of a given header.

        @param name: The name of the HTTP header to check for.

        @return: C{True} if the header exists, otherwise C{False}.
        )r=r&r<s  r�	hasHeaderzHeaders.hasHeader�s ������%��)9�)9�9�9r c�Z�|jj|j|�d�y)z�
        Remove the named header from this header object.

        @param name: The name of the HTTP header to remove.

        @return: L{None}
        N)r&�popr=r<s  r�removeHeaderzHeaders.removeHeader�s%��	
�����T�-�-�d�3�T�:r r*c��yr%��r)rr*s   rr(zHeaders.setRawHeaders����r c��yr%rFrGs   rr(zHeaders.setRawHeaders�rHr c��yr%rFrGs   rr(zHeaders.setRawHeaders�s��	r c	��t|t�std|�dt|��d���t|tt
f�stdt|��d���t
|�D]6\}}t|tt
f�r�td|�dt|��d���t|j|��}g}|D]@}t|t
�r|jd�}n|}|jt|���B||j|<y	)
a�
        Sets the raw representation of the given header.

        @param name: The name of the HTTP header to set the values for.

        @param values: A list of strings each one being a header value of
            the given name.

        @raise TypeError: Raised if C{values} is not a sequence of L{bytes}
            or L{str}, or if C{name} is not L{bytes} or L{str}.

        @return: L{None}
        z
Header entry z* should be sequence but found instance of z instead�Header name is an instance of �, not bytes or strzHeader value at position z is an instance of �utf8N)r3�	_Sequence�	TypeError�type�bytesr9�	enumeraterr=r;�appendr&)	r)rr*�count�value�_name�
encodedValues�v�_vs	         rr(zHeaders.setRawHeaders�s���&�)�,��,0�$�v�,�@��
�
�$����-��0��d���>P�Q��
�&�f�-�		�L�E�5��e�e�S�\�2����U��	���		�*�$�*:�*:�4�*@�A��%'�
��	@�A��!�S�!��X�X�f�%����� � �!:�2�!>�?�	@�#0�����r rVc��t|ttf�stdt	|��d���t|ttf�stdt	|��d���|j
j
t|j|��g�jtt|t�r|jd���y|��y)z�
        Add a new raw value for the given header.

        @param name: The name of the header for which to set the value.

        @param value: The value to set for the named header.
        rLrMzHeader value is an instance of rNN)r3rRr9rPrQr&�
setdefaultrr=rTr;)r)rrVs   r�addRawHeaderzHeaders.addRawHeader�s����$����-��0��d���>P�Q��
��%�%���.��"&�u�+�0��
�
	
���#�#�%�d�&6�&6�t�&<�=�r�	
�
�&�%�(2�5�#�(>����V�$�
�
�DI�
�
r c��yr%rFr<s  r�
getRawHeaderszHeaders.getRawHeaders�rHr �defaultc��yr%rF)r)rr`s   rr_zHeaders.getRawHeaders�rHr c���|j|�}|jj|g�}|s|St|t�r|D�cgc]}|jd���c}S|Scc}w)a�
        Returns a sequence of headers matching the given name as the raw string
        given.

        @param name: The name of the HTTP header to get the values of.

        @param default: The value to return if no header with the given C{name}
            exists.

        @return: If the named header is present, a sequence of its
            values.  Otherwise, C{default}.
        rN)r=r&�getr3r9�decode)r)rr`�encodedNamer*rYs      rr_zHeaders.getRawHeaders�sb���&�&�t�,���!�!�%�%�k�2�6����N��d�C� �.4�5��A�H�H�V�$�5�5��
��6s�A#c#�zK�|jj�D]\}}|j|�|f���y�w)z�
        Return an iterator of key, value pairs of all headers contained in this
        object, as L{bytes}.  The keys are capitalized in canonical
        capitalization.
        N)r&r'�_canonicalNameCaps)r)�krYs   r�getAllRawHeaderszHeaders.getAllRawHeaderss@�����$�$�*�*�,�	0�D�A�q��)�)�!�,�a�/�/�	0�s�9;c�L�|jj|t|��S)z�
        Return the canonical name for the given header.

        @param name: The all-lowercase header name to capitalize in its
            canonical form.

        @return: The canonical name of the header.
        )�
_caseMappingsrcrr<s  rrgzHeaders._canonicalNameCapss"���!�!�%�%�d�O�D�,A�B�Br r%)r/�
__module__�__qualname__�__doc__rkr	rrrr+r9r1r7rrRr=r?�boolrArDr
r(�objectr]r_rrr
rirgrFr rr"r"4s����*'�����0�0��M�CG�1��W�V�X�f�-=�%=�>�?�1�
�1�
�#�
�	���c�5�j� 1��e��0�:�f�:��:�;��;�D�;���%��U�
�"3��X�e�_��QU������%��U�
�"3��X�c�]��t�������#�u�*�%��/7��c�5�j�8I�/J��	
����
-0�%��U�
�"3�-0�V�-0��-0�^
��s�E�z�!2�
�5��e��;L�
�QU�
�6��&��X�h�v�6F�-G������&��2��%���@P�RT�@T�:U����59����%-�b�\��	�x����"��-�	.��00�(�5�����1G�+H�"I�0�	C�u�	C��	Cr r"N)rn�collections.abcrrO�typingrrrrrr	r
rrr
�twisted.python.compatrrrrRrrr"�__all__rFr r�<module>rus���
�2�����2��T�]��G�%�G�E�G�	3�u�	3��	3��oC�oC��oC�d�+�r 

Zerion Mini Shell 1.0