• File: response.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib/python3.7/site-packages/paste/__pycache__/response.cpython-37.pyc
  • Date Modified: 12/01/2019 7:09 PM
  • File size: 7.57 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

aN@s^dZddlZGdddeZddZddZd	d
ZddZdddZdddZ	dddZ
dS)z#Routines to generate WSGI responsesNc@seZdZdZddZddZddZdd	ZeZdddZ	dd
dZ
ddZddZddZ
ddZddZddZeeZd
S)
HeaderDictaI
    This represents response headers.  It handles the headers as a
    dictionary, with case-insensitive keys.

    Also there is an ``.add(key, value)`` method, which sets the key,
    or adds the value to the current value (turning it into a list if
    necessary).

    For passing to WSGI there is a ``.headeritems()`` method which is
    like ``.items()`` but unpacks value that are lists.  It also
    handles encoding -- all headers are encoded in ASCII (if they are
    unicode).

    @@: Should that encoding be ISO-8859-1 or UTF-8?  I'm not sure
    what the spec says.
    cCst|||S)N)dict__getitem__	normalize)selfkeyr?/opt/alt/python37/lib/python3.7/site-packages/paste/response.pyrszHeaderDict.__getitem__cCst||||dS)N)r__setitem__r)rrvaluerrr	r
 szHeaderDict.__setitem__cCst|||dS)N)r__delitem__r)rrrrr	r#szHeaderDict.__delitem__cCst|||S)N)r__contains__r)rrrrr	r
&szHeaderDict.__contains__NcCst||||S)N)rgetr)rrfailobjrrr	r+szHeaderDict.getcCst||||S)N)r
setdefaultr)rrrrrr	r.szHeaderDict.setdefaultcGstj|||f|S)N)rpopr)rrargsrrr	r1szHeaderDict.popcCs$x|D]}|||||<qWdS)N)r)rotherrrrr	update4s
zHeaderDict.updatecCst|S)N)strlowerstrip)rrrrr	r8szHeaderDict.normalizecCsN||}||krBt||tr0|||qJ|||g||<n|||<dS)N)r
isinstancelistappend)rrrrrr	add;s
zHeaderDict.addcCs\g}xR|D]F\}}t|trBx2|D]}||t|fq&Wq||t|fqW|S)N)itemsrrrr)rresultrrvrrr	headeritemsEs

zHeaderDict.headeritemscCs(|}x|D]\}}|||qW|S)N)r)clsseqrnamerrrr	fromlistPszHeaderDict.fromlist)N)N)__name__
__module____qualname____doc__rr
rr
Zhas_keyrrrrrrrr#classmethodrrrr	r
s


rcCs.|}x |D]\}}||krdSqWdS)z6
    Is header named ``name`` present in headers?
    TF)r)headersr"headerrrrr	
has_headerXs
r+cs0fdd|D}|r(d|SdSdS)a
    Returns the header's value, or None if no such header.  If a
    header appears more than once, all the values of the headers
    are joined with ','.   Note that this is consistent /w RFC 2616
    section 4.2 which states:

        It MUST be possible to combine the multiple header fields
        into one "field-name: field-value" pair, without changing
        the semantics of the message, by appending each subsequent
        field-value to the first, each separated by a comma.

    However, note that the original netscape usage of 'Set-Cookie',
    especially in MSIE which contains an 'expires' date will is not
    compatible with this particular concatination method.
    cs g|]\}}|kr|qSr)r).0r*r)r"rr	
<listcomp>ssz header_value.<locals>.<listcomp>,N)rjoin)r)r"rr)r"r	header_valuebs

r0cCsV|}d}d}x@|t|krP||d|krF||d}||=q|d7}qW|S)z
    Removes the named header from the list of headers.  Returns the
    value of that header, or None if no header found.  If multiple
    headers are found, only the last one is returned.
    rN)rlen)r)r"irrrr	
remove_headerzsr4cCs||}d}d}xT|t|krd||d|krZ|rBtd|||d}||f||<|d7}qW|sx|||f|S)a
    Updates the headers replacing the first occurance of the given name
    with the value provided; asserting that no further occurances
    happen. Note that this is _not_ the same as remove_header and then
    append, as two distinct operations (del followed by an append) are
    not atomic in a threaded environment. Returns the previous header
    value for the provided name, if any.   Clearly one should not use
    this function with ``set-cookie`` or other names that may have more
    than one occurance in the headers.
    rNz$two values for the header '%s' foundr1)rr2AssertionErrorr)r)r"rr3rrrr	replace_headersr6TcCs |rtdtdd||dS)z[
    Returns a standard HTML response page for an HTTP error.
    **Note:** Deprecated
    zmwsgilib.error_body_response is deprecated; use the wsgi_application method on an HTTPException object insteadz~<html>
  <head>
    <title>%(error_code)s</title>
  </head>
  <body>
  <h1>%(error_code)s</h1>
  %(message)s
  </body>
</html>)
error_codemessage)warningswarnDeprecationWarning)r8r9__warnrrr	error_body_responses
r>cCs`|rtdtd|r4|didr4|d|7}t||dd}dd	tt|fg}|||fS)
a_
    Returns the status, headers, and body of an error response.

    Use like:

    .. code-block:: python

        status, headers, body = wsgilib.error_response(
            '301 Moved Permanently', 'Moved to <a href="%s">%s</a>'
            % (url, url))
        start_response(status, headers)
        return [body]

    **Note:** Deprecated
    zhwsgilib.error_response is deprecated; use the wsgi_application method on an HTTPException object insteadr7zpaste.configdebugz

<!-- %s -->F)r=)zcontent-typez	text/htmlzcontent-length)r:r;r<rr>rr2)environr8r9
debug_messager=bodyr)rrr	error_responsesrCcs&|rtdtdfdd}|S)zW
    An application that emits the given error response.

    **Note:** Deprecated
    zlwsgilib.error_response_app is deprecated; use the wsgi_application method on an HTTPException object insteadr7cs(t|dd\}}}||||gS)NF)rAr=)rC)r@Zstart_responsestatusr)rB)rAr8r9rr	applications

z'error_response_app.<locals>.application)r:r;r<)r8r9rAr=rEr)rAr8r9r	error_response_appsrF)T)NT)NT)r'r:rrr+r0r4r6r>rCrFrrrr	<module>sN