OpenQuizz
Une application de gestion des contenus pédagogiques
ETagResponseMixin Class Reference
Inheritance diagram for ETagResponseMixin:
Collaboration diagram for ETagResponseMixin:

Public Member Functions

def cache_control (self)
 
def make_conditional (self, request_or_environ, accept_ranges=False, complete_length=None)
 
def add_etag (self, overwrite=False, weak=False)
 
def set_etag (self, etag, weak=False)
 
def get_etag (self)
 
def freeze (self, no_etag=False)
 
def content_range (self)
 
def content_range (self, value)
 

Data Fields

 status_code
 
 response
 
 content_range
 

Static Public Attributes

 accept_ranges
 
 doc
 

Detailed Description

Adds extra functionality to a response object for etag and cache
handling.  This mixin requires an object with at least a `headers`
object that implements a dict like interface similar to
:class:`~werkzeug.datastructures.Headers`.

If you want the :meth:`freeze` method to automatically add an etag, you
have to mixin this method before the response base class.  The default
response class does not do that.

Member Function Documentation

◆ add_etag()

def add_etag (   self,
  overwrite = False,
  weak = False 
)
Add an etag for the current response if there is none yet.

◆ cache_control()

def cache_control (   self)
The Cache-Control general-header field is used to specify
directives that MUST be obeyed by all caching mechanisms along the
request/response chain.

◆ content_range() [1/2]

def content_range (   self)
The ``Content-Range`` header as a
:class:`~werkzeug.datastructures.ContentRange` object. Available
even if the header is not set.

.. versionadded:: 0.7

◆ content_range() [2/2]

def content_range (   self,
  value 
)

◆ freeze()

def freeze (   self,
  no_etag = False 
)
Call this method if you want to make your response object ready for
pickeling.  This buffers the generator if there is one.  This also
sets the etag unless `no_etag` is set to `True`.

◆ get_etag()

def get_etag (   self)
Return a tuple in the form ``(etag, is_weak)``.  If there is no
ETag the return value is ``(None, None)``.

◆ make_conditional()

def make_conditional (   self,
  request_or_environ,
  accept_ranges = False,
  complete_length = None 
)
Make the response conditional to the request.  This method works
best if an etag was defined for the response already.  The `add_etag`
method can be used to do that.  If called without etag just the date
header is set.

This does nothing if the request method in the request or environ is
anything but GET or HEAD.

For optimal performance when handling range requests, it's recommended
that your response data object implements `seekable`, `seek` and `tell`
methods as described by :py:class:`io.IOBase`.  Objects returned by
:meth:`~werkzeug.wsgi.wrap_file` automatically implement those methods.

It does not remove the body of the response because that's something
the :meth:`__call__` function does for us automatically.

Returns self so that you can do ``return resp.make_conditional(req)``
but modifies the object in-place.

:param request_or_environ: a request object or WSGI environment to be
                   used to make the response conditional
                   against.
:param accept_ranges: This parameter dictates the value of
              `Accept-Ranges` header. If ``False`` (default),
              the header is not set. If ``True``, it will be set
              to ``"bytes"``. If ``None``, it will be set to
              ``"none"``. If it's a string, it will use this
              value.
:param complete_length: Will be used only in valid Range Requests.
                It will set `Content-Range` complete length
                value and compute `Content-Length` real value.
                This parameter is mandatory for successful
                Range Requests completion.
:raises: :class:`~werkzeug.exceptions.RequestedRangeNotSatisfiable`
 if `Range` header could not be parsed or satisfied.

◆ set_etag()

def set_etag (   self,
  etag,
  weak = False 
)
Set the etag, and override the old one if there was one.

Field Documentation

◆ accept_ranges

accept_ranges
static

◆ content_range

content_range

◆ doc

doc
static

◆ response

response

◆ status_code

status_code

The documentation for this class was generated from the following file: