Package cherrypy :: Module _cprequest :: Class Response
[hide private]
[frames] | no frames]

Class Response

source code

object --+
         |
        Response

An HTTP Response, including status, headers, and body.
    
    Application developers should use Response.headers (a dict) to
    set or modify HTTP response headers. When the response is finalized,
    Response.headers is transformed into Response.header_list as
    (key, value) tuples.
    

body [= <cherrypy._cprequest.Body object at 0x405af8ec>]:
    The body (entity) of the HTTP response.

cookie [= <SimpleCookie: >]:
    See help(Cookie).

header_list [= []]:
    A list of the HTTP response headers as (name, value) tuples.
    In general, you should use response.headers (a dict) instead.

headers [= {}]:
    A dict-like object containing the response headers. Keys are header
    names (in Title-Case format); however, you may get and set them in
    a case-insensitive manner. That is, headers['Content-Type'] and
    headers['content-type'] refer to the same value. Values are header
    values (decoded according to RFC 2047 if necessary). See also:
    http.HeaderMap, http.HeaderElement.

status [= '']:
    The HTTP Status-Code and Reason-Phrase.

stream [= False]:
    If False, buffer the response body.

time [= None]:
    The value of time.time() when created. Use in HTTP dates.

timed_out [= False]:
    Flag to indicate the response should be aborted, because it has
    exceeded its timeout.

timeout [= 300]:
    Seconds after which the response will be aborted.



Nested Classes [hide private]
  __metaclass__
Metaclass for declaring docstrings for class attributes.
Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
collapse_body(self)
Iterate over self.body, replacing it with and returning the result.
source code
 
finalize(self)
Transform headers (and cookies) into self.header_list.
source code
 
check_timeout(self)
If now > self.time + self.timeout, set self.timed_out.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variables [hide private]
  status = ''
  status__doc = """The HTTP Status-Code and Reason-Phrase."""
  header_list = []
  header_list__doc = ...
  headers = {}
  headers__doc = ...
  cookie = <SimpleCookie: >
  cookie__doc = """See help(Cookie)."""
  body = Body()
  body__doc = """The body (entity) of the HTTP response."""
  time = None
  time__doc = """The value of time.time() when created. Use in H...
  timeout = 300
  timeout__doc = """Seconds after which the response will be abo...
  timed_out = False
  timed_out__doc = ...
  stream = False
  stream__doc = """If False, buffer the response body."""
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

finalize(self)

source code 
Transform headers (and cookies) into self.header_list. (Core)

check_timeout(self)

source code 

If now > self.time + self.timeout, set self.timed_out.

This purposefully sets a flag, rather than raising an error, so that a monitor thread can interrupt the Response thread.

Class Variable Details [hide private]

header_list__doc

Value:
"""
    A list of the HTTP response headers as (name, value) tuples.
    In general, you should use response.headers (a dict) instead."""

headers__doc

Value:
"""
    A dict-like object containing the response headers. Keys are heade\
r
    names (in Title-Case format); however, you may get and set them in
    a case-insensitive manner. That is, headers['Content-Type'] and
    headers['content-type'] refer to the same value. Values are header
    values (decoded according to RFC 2047 if necessary). See also:
    http.HeaderMap, http.HeaderElement."""

time__doc

Value:
"""The value of time.time() when created. Use in HTTP dates."""

timeout__doc

Value:
"""Seconds after which the response will be aborted."""

timed_out__doc

Value:
"""
    Flag to indicate the response should be aborted, because it has
    exceeded its timeout."""