Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Calcul scientifique
avec Python
Voir le programme détaillé
Classe « Response »

Méthode flask.Response.make_conditional

Signature de la méthode make_conditional

def make_conditional(self, request_or_environ: 'WSGIEnvironment | Request', accept_ranges: 'bool | str' = False, complete_length: 'int | None' = None) -> 'Response' 

Description

help(Response.make_conditional)

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 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.

.. versionchanged:: 2.0
    Range processing is skipped if length is 0 instead of
    raising a 416 Range Not Satisfiable error.


Vous êtes un professionnel et vous avez besoin d'une formation ? Deep Learning avec Python
et Keras et Tensorflow
Voir le programme détaillé