Package wsgiwebapi :: Module wsgisupport :: Class Response
[frames] | no frames]

Class Response

source code

object --+
         |
        Response

Response object, used to return stuff via WSGI protocol.

The Response object is a container fr the details of the response. It contains three significant members:

Instance Methods
 
__init__(self, body=u'', status=200, content_type=u'text/plain')
Create a new Response object.
source code
 
get_encoded_header_list(self)
Get the list of headers, encoded suitably for HTTP.
source code
 
set_unique_header(self, header, value)
Set the value of a header which should only occur once.
source code
 
set_content_type(self, content_type)
Set the content type to return.
source code
 
__str__(self)
str(x)
source code

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

Class Variables
  VALID_STATUS_RE = re.compile(r'[12345][0-9][0-9]')
  status = property(_get_status, _set_status, doc= """The status...
Properties

Inherited from object: __class__

Method Details

__init__(self, body=u'', status=200, content_type=u'text/plain')
(Constructor)

source code 

Create a new Response object.

The body defaults to being empty, the status defaults to "200 OK", and the content_type defaults to 'text/plain'.

  • body: The value to store in the body member. Defaults to ''.

  • status: The status to set for the response. May be specified as a number, or as a string (optionally, with a reason phrase). Defaults to 200.

  • content_type: The content type to set for the response (as specified for the set_content_type() method). Defaults to 'text/plain'.

Overrides: object.__init__

get_encoded_header_list(self)

source code 

Get the list of headers, encoded suitably for HTTP.

This converts the unicode headers to byte strings, suitable for passing through HTTP.

set_unique_header(self, header, value)

source code 

Set the value of a header which should only occur once.

If any values for the header already exist in the list of headers, they are first removed. The comparison of header names is performed case insensitively.

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

Class Variable Details

status

Value:
property(_get_status, _set_status, doc= """The status line to return.

        This may be set to either a string or a number.  If a string, \
it may
        either contain only the status code, or may contain a reason p\
hrase
        following the status code (separated by a space).
        
...