AlkantarClanX12
Current Path : /opt/alt/python312/lib64/python3.12/wsgiref/__pycache__/ |
Current File : //opt/alt/python312/lib64/python3.12/wsgiref/__pycache__/headers.cpython-312.opt-1.pyc |
� �Q�fn � �P � d Z ddlZ ej d� Zdd�Z G d� d� Zy)z�Manage HTTP Response Headers Much of this module is red-handedly pilfered from email.message in the stdlib, so portions are Copyright (C) 2001,2002 Python Software Foundation, and were written by Barry Warsaw. � Nz[ \(\)<>@,;:\\"/\[\]\?=]c � � |�Vt |� dkD rH|st j |� r*|j dd� j dd� }| �d|�d�S | �d|��S | S )z~Convenience function to format and return a key=value pair. This will quote the value if needed or if quote is true. r �\z\\�"z\"z="�=)�len� tspecials�search�replace)�param�value�quotes �6/opt/alt/python312/lib64/python3.12/wsgiref/headers.py�_formatparamr s\ � � ��S��Z�!�^��I�$�$�U�+��M�M�$��/�7�7��U�C�E� %�u�-�-�#�U�+�+��� c �z � e Zd ZdZdd�Zd� Zd� Zd� Zd� Zd� Z d � Z d � Zdd�Zd� Z d � Zd� Zd� Zd� Zd� Zd� Zd� Zy)�Headersz,Manage a collection of HTTP response headersNc �V � |�|ng }t |� t urt d� �|| _ y )Nz+Headers must be a list of name/value tuples)�type�list� TypeError�_headers�_convert_string_type)�self�headers�k�vs r �__init__zHeaders.__init__ s0 � �$�0�'�b����=��$��I�J�J��� �r c �n � t |� t u r|S t dj t |� � � �)zConvert/check value type.z1Header names/values must be of type str (got {0}))r �str�AssertionError�format�repr)r r s r r zHeaders._convert_string_type) s3 � ���;�#���L�� %�%+�V�D��K�%8�:� :r c �, � t | j � S )z9Return the total number of headers, including duplicates.)r r �r s r �__len__zHeaders.__len__0 s � ��4�=�=�!�!r c � � | |= | j j | j |� | j |� f� y)zSet the value of a header.N)r �appendr )r �name�vals r �__setitem__zHeaders.__setitem__4 s: � ���J�� � ��� � &� &�t� ,�d�.G�.G��.L�M� Or c �� � | j |j � � }| j D �cg c] }|d j � |k7 s�|�� c}| j dd yc c}w )zyDelete all occurrences of a header, if present. Does *not* raise an exception if the header is missing. r N�r �lowerr �r r( �kvs r �__delitem__zHeaders.__delitem__: sO � � �(�(�����6��)-���P��2�"�Q�%�+�+�-�4�:O�B��P�� � �a���Ps �A� Ac �$ � | j |� S )aH Get the first header value for 'name' Return None if the header is missing instead of raising an exception. Note that if the header appeared multiple times, the first exactly which occurrence gets returned is undefined. Use getall() to get all the values matching a header field name. ��get�r r( s r �__getitem__zHeaders.__getitem__B s � � �x�x��~�r c �( � | j |� duS )z/Return true if the message contains the header.Nr2 r4 s r �__contains__zHeaders.__contains__M s � ��x�x��~�T�)�)r c � � | j |j � � }| j D �cg c] }|d j � |k( s�|d �� c}S c c}w )aq Return a list of all the values for the named field. These will be sorted in the order they appeared in the original header list or were added to this instance, and may contain duplicates. Any fields deleted and re-inserted are always appended to the header list. If no fields exist with the given name, returns an empty list. r � r, r. s r �get_allzHeaders.get_allR sK � � �(�(�����6�� $� � �E� �"��A������1D��1�� �E�E��Es �A� Ac � � | j |j � � }| j D ] \ }}|j � |k( s�|c S |S )z:Get the first header value for 'name', or return 'default'r, )r r( �defaultr r s r r3 zHeaders.get^ sC � ��(�(�����6���=�=�C�A�a��w�w�y�$���� !� �r c �L � | j D ��cg c] \ }}|�� c}}S c c}}w )a* Return a list of all the header field names. These will be sorted in the order they appeared in the original header list, or were added to this instance, and may contain duplicates. Any fields deleted and re-inserted are always appended to the header list. �r �r r r s r �keyszHeaders.keysg �$ � � #�m�m�,�m�d�a���m�,�,��,� � c �L � | j D ��cg c] \ }}|�� c}}S c c}}w )a! Return a list of all header values. These will be sorted in the order they appeared in the original header list, or were added to this instance, and may contain duplicates. Any fields deleted and re-inserted are always appended to the header list. r>