Your IP : 3.21.244.240


Current Path : /opt/alt/python33/lib64/python3.3/wsgiref/__pycache__/
Upload File :
Current File : //opt/alt/python33/lib64/python3.3/wsgiref/__pycache__/headers.cpython-33.pyo

�
��fc@sJdZddlZejd�Zdddd�ZGdd�d�ZdS(	u�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.
iNu[ \(\)<>@,;:\\"/\[\]\?=]icCsx|dk	rpt|�dkrp|s3tj|�r_|jdd�jdd�}d||fSd||fSn|SdS(	u~Convenience function to format and return a key=value pair.

    This will quote the value if needed or if quote is true.
    iu\u\\u"u\"u%s="%s"u%s=%sN(uNoneulenu	tspecialsusearchureplace(uparamuvalueuquote((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyu_formatparam
su_formatparamcBs�|EeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zd$dd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$S(%uHeadersu,Manage a collection of HTTP response headerscCs.t|�tk	r!td��n||_dS(Nu+Headers must be a list of name/value tuples(utypeulistu	TypeErroru_headers(uselfuheaders((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyu__init__ s	uHeaders.__init__cCs5t|�tkr|Stdjt|����dS(uConvert/check value type.u1Header names/values must be of type str (got {0})N(utypeustruAssertionErroruformaturepr(uselfuvalue((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyu_convert_string_type)s	uHeaders._convert_string_typecCs
t|j�S(u9Return the total number of headers, including duplicates.(ulenu_headers(uself((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyu__len__0suHeaders.__len__cCs3||=|jj|j|�|j|�f�dS(uSet the value of a header.N(u_headersuappendu_convert_string_type(uselfunameuval((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyu__setitem__4s	uHeaders.__setitem__csB|j�j����fdd�|jD�|jdd�<dS(uyDelete all occurrences of a header, if present.

        Does *not* raise an exception if the header is missing.
        cs,g|]"}|dj��kr|�qS(i(ulower(u.0ukv(uname(u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyu
<listcomp>@s	u'Headers.__delitem__.<locals>.<listcomp>N(u_convert_string_typeuloweru_headers(uselfuname((unameu4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyu__delitem__:suHeaders.__delitem__cCs
|j|�S(uHGet 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
        occurrance gets returned is undefined.  Use getall() to get all
        the values matching a header field name.
        (uget(uselfuname((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyu__getitem__Bs	uHeaders.__getitem__cCs|j|�dk	S(u/Return true if the message contains the header.N(ugetuNone(uselfuname((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyu__contains__MsuHeaders.__contains__cs/|j�j����fdd�|jD�S(uqReturn 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.
        cs0g|]&}|dj��kr|d�qS(ii(ulower(u.0ukv(uname(u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyu
<listcomp>[s	u#Headers.get_all.<locals>.<listcomp>(u_convert_string_typeuloweru_headers(uselfuname((unameu4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyuget_allRsuHeaders.get_allcCsI|j|j��}x-|jD]"\}}|j�|kr|SqW|S(u:Get the first header value for 'name', or return 'default'(u_convert_string_typeuloweru_headers(uselfunameudefaultukuv((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyuget^s
uHeaders.getcCsdd�|jD�S(u*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.
        cSsg|]\}}|�qS(((u.0ukuv((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyu
<listcomp>os	u Headers.keys.<locals>.<listcomp>(u_headers(uself((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyukeysgsuHeaders.keyscCsdd�|jD�S(u!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.
        cSsg|]\}}|�qS(((u.0ukuv((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyu
<listcomp>ys	u"Headers.values.<locals>.<listcomp>(u_headers(uself((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyuvaluesqsuHeaders.valuescCs|jdd�S(uGet all the header fields and values.

        These will be sorted in the order they were 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.
        N(u_headers(uself((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyuitems{su
Headers.itemscCsd|jS(NuHeaders(%r)(u_headers(uself((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyu__repr__�suHeaders.__repr__cCs'djdd�|jD�ddg�S(ukstr() returns the formatted headers, complete with end line,
        suitable for direct HTTP transmission.u
cSsg|]}d|�qS(u%s: %s((u.0ukv((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyu
<listcomp>�s	u#Headers.__str__.<locals>.<listcomp>u(ujoinu_headers(uself((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyu__str__�suHeaders.__str__cCst|�jd�S(Nu
iso-8859-1(ustruencode(uself((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyu	__bytes__�suHeaders.__bytes__cCsO|j|�}|dkrG|jj|j|�|j|�f�|S|SdS(u�Return first matching header value for 'name', or 'value'

        If there is no header named 'name', add a new header with name 'name'
        and value 'value'.N(ugetuNoneu_headersuappendu_convert_string_type(uselfunameuvalueuresult((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyu
setdefault�suHeaders.setdefaultcKs�g}|dk	r1|j|�}|j|�nx�|j�D]t\}}|j|�}|dkr�|j|jdd��q>|j|�}|jt|jdd�|��q>W|jj|j|�dj|�f�dS(ufExtended header setting.

        _name is the header field to add.  keyword arguments can be used to set
        additional parameters for the header field, with underscores converted
        to dashes.  Normally the parameter will be added as key="value" unless
        value is None, in which case only the key will be added.

        Example:

        h.add_header('content-disposition', 'attachment', filename='bud.gif')

        Note that unlike the corresponding 'email.message' method, this does
        *not* handle '(charset, language, value)' tuples: all values must be
        strings or None.
        u_u-u; N(uNoneu_convert_string_typeuappenduitemsureplaceu_formatparamu_headersujoin(uselfu_nameu_valueu_paramsupartsukuv((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyu
add_header�s&uHeaders.add_headerN(u__name__u
__module__u__qualname__u__doc__u__init__u_convert_string_typeu__len__u__setitem__u__delitem__u__getitem__u__contains__uget_alluNoneugetukeysuvaluesuitemsu__repr__u__str__u	__bytes__u
setdefaultu
add_header(u
__locals__((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyuHeaderss$		



uHeaders(u__doc__ureucompileu	tspecialsuNoneu_formatparamuHeaders(((u4/opt/alt/python33/lib64/python3.3/wsgiref/headers.pyu<module>s

?>