class BaseResponse(object): (source)
Known subclasses: bottle.LocalResponse
, bottle.HTTPResponse
Storage class for a response body as well as headers and cookies. This class does support dict-like case-insensitive item-access to headers, but is NOT a dict. Most notably, iterating over a response yields parts of the body and not the headers. :param body: The response body as one of the supported types. :param status: Either an HTTP status code (e.g. 200) or a status line including the reason phrase (e.g. '200 OK'). :param headers: A dictionary or a list of name-value pairs. Additional keyword arguments are added to the list of headers. Underscores in the header name are replaced with dashes.
Method | __contains__ |
Undocumented |
Method | __delitem__ |
Undocumented |
Method | __getitem__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | __iter__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | __setitem__ |
Undocumented |
Method | add |
Add an additional response header, not removing duplicates. |
Method | close |
Undocumented |
Method | copy |
Returns a copy of self. |
Method | delete |
Delete a cookie. Be sure to use the same `domain` and `path` settings as used to create the cookie. |
Method | get |
Return the value of a previously defined header. If there is no header with that name, return a default value. |
Method | iter |
Yield (header, value) tuples, skipping headers that are not allowed with the current response status code. |
Method | set |
Create a new cookie or replace an old one. If the `secret` parameter is set, create a `Signed Cookie` (described below). |
Method | set |
Create a new response header, replacing any previously defined headers with the same name. |
Class Variable | bad |
Undocumented |
Class Variable | content |
Undocumented |
Class Variable | content |
Undocumented |
Class Variable | default |
Undocumented |
Class Variable | default |
Undocumented |
Class Variable | expires |
Undocumented |
Instance Variable | body |
Undocumented |
Instance Variable | status |
Undocumented |
Property | charset |
Return the charset specified in the content-type header (default: utf8). |
Property | headerlist |
WSGI conform list of (header, value) tuples. |
Property | headers |
An instance of :class:`HeaderDict`, a case-insensitive dict-like view on the response headers. |
Property | status |
The HTTP status code as an integer (e.g. 404). |
Property | status |
The HTTP status line as a string (e.g. ``404 Not Found``). |
Method | _get |
Undocumented |
Method | _set |
Undocumented |
Instance Variable | _cookies |
Undocumented |
Instance Variable | _headers |
Undocumented |
Instance Variable | _status |
Undocumented |
Instance Variable | _status |
Undocumented |
Return the value of a previously defined header. If there is no header with that name, return a default value.
Yield (header, value) tuples, skipping headers that are not allowed with the current response status code.
Create a new cookie or replace an old one. If the `secret` parameter is set, create a `Signed Cookie` (described below). :param name: the name of the cookie. :param value: the value of the cookie. :param secret: a signature key required for signed cookies. Additionally, this method accepts all RFC 2109 attributes that are supported by :class:`cookie.Morsel`, including: :param max_age: maximum age in seconds. (default: None) :param expires: a datetime object or UNIX timestamp. (default: None) :param domain: the domain that is allowed to read the cookie. (default: current domain) :param path: limits the cookie to a given path (default: current path) :param secure: limit the cookie to HTTPS connections (default: off). :param httponly: prevents client-side javascript to read this cookie (default: off, requires Python 2.6 or newer). If neither `expires` nor `max_age` is set (default), the cookie will expire at the end of the browser session (as soon as the browser window is closed). Signed cookies may store any pickle-able object and are cryptographically signed to prevent manipulation. Keep in mind that cookies are limited to 4kb in most browsers. Warning: Signed cookies are not encrypted (the client can still see the content) and not copy-protected (the client can restore an old cookie). The main intention is to make pickling and unpickling save, not to store secret information at client side.