%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python3.8/wsgiref/__pycache__/
Upload File :
Create Path :
Current File : //usr/local/lib/python3.8/wsgiref/__pycache__/headers.cpython-38.pyc

U

pan@s2dZddlZedZd	ddZGdddZdS)
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[ \(\)<>@,;:\\"/\[\]\?=]cCsX|dk	rPt|dkrP|s"t|rB|dddd}d||fSd||fSn|SdS)	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)Zparamvaluequoter+/usr/local/lib/python3.8/wsgiref/headers.py_formatparam
sr
c@seZdZdZd%ddZddZddZd	d
ZddZd
dZ	ddZ
ddZd&ddZddZ
ddZddZddZddZdd Zd!d"Zd#d$ZdS)'Headersz,Manage a collection of HTTP response headersNcCsP|dk	r|ng}t|tk	r$td||_|D]\}}||||q.dS)Nz+Headers must be a list of name/value tuples)typelist	TypeError_headers_convert_string_type)selfZheaderskvrrr__init__s
zHeaders.__init__cCs&t|tkr|Stdt|dS)zConvert/check value type.z1Header names/values must be of type str (got {0})N)rstrAssertionErrorformatrepr)rr	rrrr)s
zHeaders._convert_string_typecCs
t|jS)z9Return the total number of headers, including duplicates.)rrrrrr__len__0szHeaders.__len__cCs&||=|j||||fdS)zSet the value of a header.N)rappendr)rnamevalrrr__setitem__4szHeaders.__setitem__cs0|fdd|jD|jdd<dS)zyDelete all occurrences of a header, if present.

        Does *not* raise an exception if the header is missing.
        cs g|]}|dkr|qS)rlower.0Zkvrrr
<listcomp>@sz'Headers.__delitem__.<locals>.<listcomp>Nrr#rrrrr&r__delitem__:szHeaders.__delitem__cCs
||S)aHGet 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.
        getr)rrr__getitem__Bs	zHeaders.__getitem__cCs||dk	S)z/Return true if the message contains the header.Nr+r)rrr__contains__MszHeaders.__contains__cs"|fdd|jDS)aqReturn 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.
        cs$g|]}|dkr|dqS)rrr"r$r&rrr'[sz#Headers.get_all.<locals>.<listcomp>r(r)rr&rget_allRszHeaders.get_allcCs6||}|jD]\}}||kr|Sq|S)z:Get the first header value for 'name', or return 'default'r()rrdefaultrrrrrr,^s

zHeaders.getcCsdd|jDS)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.
        cSsg|]\}}|qSrrr%rrrrrr'osz Headers.keys.<locals>.<listcomp>rrrrrkeysgszHeaders.keyscCsdd|jDS)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.
        cSsg|]\}}|qSrrr1rrrr'ysz"Headers.values.<locals>.<listcomp>r2rrrrvaluesqszHeaders.valuescCs|jddS)aGet 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.
        Nr2rrrritems{sz
Headers.itemscCsd|jj|jfS)Nz%s(%r))	__class____name__rrrrr__repr__szHeaders.__repr__cCsddd|jDddgS)zkstr() returns the formatted headers, complete with end line,
        suitable for direct HTTP transmission.z
cSsg|]}d|qS)z%s: %srr$rrrr'sz#Headers.__str__.<locals>.<listcomp>)joinrrrrr__str__szHeaders.__str__cCst|dS)Nz
iso-8859-1)rencoderrrr	__bytes__szHeaders.__bytes__cCs:||}|dkr2|j||||f|S|SdS)zReturn 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)r,rrr)rrr	resultrrr
setdefaults
zHeaders.setdefaultcKsg}|dk	r ||}|||D]P\}}||}|dkrV||ddq(||}|t|dd|q(|j||d|fdS)afExtended 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.
        N_-z; )rrr5rr
rr:)r_name_valueZ_paramspartsrrrrr
add_headers



zHeaders.add_header)N)N)r7
__module____qualname____doc__rrrr!r*r-r.r/r,r3r4r5r8r;r=r?rErrrrrs$


	



r)Nr)rHrecompilerr
rrrrr<module>s	



Zerion Mini Shell 1.0