o 0i @ sF d Z ddlZedZedZedZdddZG d d d ZdS )zManage 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[ \(\)<>@,;:\\"/\[\]\?=]z[\x00-\x1F\x7F]z[\x00-\x08\x0A-\x1F\x7F] c C sR |dur't |dkr'|st|r!|dddd}d| |f S d| |f 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. Nr \z\\"z\"z%s="%s"z%s=%s)len tspecialssearchreplace)ZparamvalueZquote r 6/opt/alt/python310/lib64/python3.10/wsgiref/headers.py_formatparam s r c @ s e Zd ZdZd%ddZdd Zdd Zd d Zdd Zd d Z dd Z dd Zd%ddZdd Z dd Zdd Zdd Zdd Zdd Zd!d" Zd#d$ ZdS )&Headersz,Manage a collection of HTTP response headersNc C s. |d ur|ng }t |turtd|| _d S )Nz+Headers must be a list of name/value tuples)typelist TypeError_headers_convert_string_type)selfZheaderskvr r r __init__$ s zHeaders.__init__c C s@ t |tu r|r tnt}||rtd|S tdt|)zConvert/check value type.z)Control characters not allowed in headersz1Header names/values must be of type str (got {0})) r str_name_disallowed_re_value_disallowed_rer ValueErrorAssertionErrorformatrepr)r r nameZregexr r r r . s zHeaders._convert_string_typec C s t | jS )z9Return the total number of headers, including duplicates.)r r r r r r __len__8 s zHeaders.__len__c C s. | |= | j | j|dd| j|ddf dS )zSet the value of a header.Tr FN)r appendr )r r valr r r __setitem__<