werkzeug.Response¶

class werkzeug.Response(response=None, status=None, headers=None, mimetype=None, content_type=None, direct_passthrough=False)[source]

Full featured response object implementing the following mixins:

Methods¶

 __init__([response, status, headers, ...]) add_etag([overwrite, weak]) Add an etag for the current response if there is none yet. calculate_content_length() Returns the content length if available or None otherwise. call_on_close(func) Adds a function to the internal list of functions that should be called as part of closing down the response. close() Close the wrapped response if possible. delete_cookie(key[, path, domain]) Delete a cookie. force_type(response[, environ]) Enforce that the WSGI response is a response object of the current type. freeze() Call this method if you want to make your response object ready for being pickled. from_app(app, environ[, buffered]) Create a new response object from an application output. get_app_iter(environ) Returns the application iterator for the given environ. get_data([as_text]) The string representation of the request body. get_etag() Return a tuple in the form (etag, is_weak). get_wsgi_headers(environ) This is automatically called right before the response is started and returns headers modified for the given environment. get_wsgi_response(environ) Returns the final WSGI response as tuple. iter_encoded() Iter the response encoded with the encoding of the response. make_conditional(request_or_environ) Make the response conditional to the request. make_sequence() Converts the response iterator in a list. set_cookie(key[, value, max_age, expires, ...]) Sets a cookie. set_data(value) Sets a new string as response. set_etag(etag[, weak]) Set the etag, and override the old one if there was one.

Attributes¶

 accept_ranges The Accept-Ranges header. age The Age response-header field conveys the sender’s estimate of the amount of time since the response (or its revalidation) was generated at the origin server. allow The Allow entity-header field lists the set of methods supported by the resource identified by the Request-URI. autocorrect_location_header automatically_set_content_length cache_control The Cache-Control general-header field is used to specify directives that MUST be obeyed by all caching mechanisms along the request/response chain. charset content_encoding The Content-Encoding entity-header field is used as a modifier to the media-type. content_language The Content-Language entity-header field describes the natural language(s) of the intended audience for the enclosed entity. content_length The Content-Length entity-header field indicates the size of the entity-body, in decimal number of OCTETs, sent to the recipient or, in the case of the HEAD method, the size of the entity-body that would have been sent had the request been a GET. content_location The Content-Location entity-header field MAY be used to supply the resource location for the entity enclosed in the message when that entity is accessible from a location separate from the requested resource’s URI. content_md5 The Content-MD5 entity-header field, as defined in RFC 1864, is an MD5 digest of the entity-body for the purpose of providing an end-to-end message integrity check (MIC) of the entity-body. content_range The Content-Range header as ContentRange object. content_type The Content-Type entity-header field indicates the media type of the entity-body sent to the recipient or, in the case of the HEAD method, the media type that would have been sent had the request been a GET. data A descriptor that calls get_data() and set_data(). date The Date general-header field represents the date and time at which the message was originated, having the same semantics as orig-date in RFC 822. default_mimetype default_status expires The Expires entity-header field gives the date/time after which the response is considered stale. implicit_sequence_conversion is_sequence If the iterator is buffered, this property will be True. is_streamed If the response is streamed (the response is not an iterable with a length information) this property is True. last_modified The Last-Modified entity-header field indicates the date and time at which the origin server believes the variant was last modified. location The Location response-header field is used to redirect the recipient to a location other than the Request-URI for completion of the request or identification of a new resource. mimetype The mimetype (content type without charset etc.) mimetype_params The mimetype parameters as dict. retry_after The Retry-After response-header field can be used with a 503 (Service Unavailable) response to indicate how long the service is expected to be unavailable to the requesting client. status The HTTP Status code status_code The HTTP Status code as number stream The response iterable as write-only stream. vary The Vary field value indicates the set of request-header fields that fully determines, while the response is fresh, whether a cache is permitted to use the response to reply to a subsequent request without revalidation. www_authenticate The WWW-Authenticate header in a parsed form.