Current File : //proc/self/root/lib/python3/dist-packages/twisted/web/__pycache__/http_headers.cpython-312.pyc |
�
Ϫ�fs# � � � d Z ddlmZ ddlmZmZmZmZm Z m
Z
mZmZmZm
Z
mZ ddlmZmZ ed� Zdedefd�Zd edefd
�Ze G d� d� � ZdgZy
)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 | j d� D �cg c] }|j � �� c}� S c c}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�_dashCapitalizer s1 � � �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)r s r �_sanitizeLinearWhitespacer ( s � � �9�9�_�/�/�1�2�2� c
�4 � e Zd ZdZdddddddd �Z d"deeeee f dd
fd
�Z de
fd�Zd� Zde
e
ef defd�Zd� Zdedefd�Zdedd
fd�Zede
e
ef dee dd
fd�� Zede
e
ef dee
dd
fd�� Zede
e
ef dee
e
ef dd
fd�� Zde
e
ef dedd
fd�Zde
e
ef de
e
ef dd
fd�Zededeee fd�� Zededede
ee ef fd�� Z d"dedee de
ee ee f fd�Zdeeeee f fd �Zdedefd!�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}.
s Content-MD5s DNTs ETags P3Ps TEs WWW-Authenticates X-XSS-Protection)s content-md5s dnts etags p3ps tes www-authenticates x-xss-protectionN�
rawHeadersr c �l � i | _ |�+|j � D ] \ }}| j ||� � y y �N)�_rawHeaders�items�
setRawHeaders)�selfr# r �valuess r �__init__zHeaders.__init__T sC � � 68����!� *� 0� 0� 2�
1���f��"�"�4��0�
1� "r c �b � dj | j j | j � S )zR
Return a string fully describing the headers set on this object.
z{}({!r}))�format� __class__�__name__r&