summaryrefslogtreecommitdiff
path: root/docs/topics/conditional-view-processing.txt
diff options
context:
space:
mode:
authorJosh Schneier <josh.schneier@gmail.com>2017-06-06 15:37:14 -0400
committerTim Graham <timograham@gmail.com>2017-06-06 15:37:14 -0400
commit37c9b81ebc9af3b61345a070a143ee8330a119b4 (patch)
tree5f2597de32d937fd05dc11b589da66a6fb833078 /docs/topics/conditional-view-processing.txt
parent268a646353c6fa9e5fc3730e13b386ddabb018ef (diff)
Fixed #28104 -- Prevented condition decorator from setting ETag/Last-Modified headers for non-safe requests.
Diffstat (limited to 'docs/topics/conditional-view-processing.txt')
-rw-r--r--docs/topics/conditional-view-processing.txt12
1 files changed, 12 insertions, 0 deletions
diff --git a/docs/topics/conditional-view-processing.txt b/docs/topics/conditional-view-processing.txt
index 02bf4635a8..935c33be34 100644
--- a/docs/topics/conditional-view-processing.txt
+++ b/docs/topics/conditional-view-processing.txt
@@ -66,6 +66,10 @@ last time the resource was modified, or ``None`` if the resource doesn't
exist. The function passed to the ``etag`` decorator should return a string
representing the `ETag`_ for the resource, or ``None`` if it doesn't exist.
+The decorator sets the ``ETag`` and ``Last-Modified`` headers on the response
+if they are not already set by the view and if the request's method is safe
+(``GET`` or ``HEAD``).
+
.. versionchanged:: 1.11
In older versions, the return value from ``etag_func()`` was interpreted as
@@ -198,6 +202,14 @@ to compute the ETag and last modification values in all situations. In fact,
you **should** use the same functions, so that the same values are returned
every time.
+.. admonition:: Validator headers with non-safe request methods
+
+ The ``condition`` decorator only sets validator headers (``ETag`` and
+ ``Last-Modified``) for safe HTTP methods, i.e. ``GET`` and ``HEAD``. If you
+ wish to return them in other cases, set them in your view. See
+ :rfc:`7231#section-4.3.4` to learn about the distinction between setting a
+ validator header in response to requests made with ``PUT`` versus ``POST``.
+
Comparison with middleware conditional processing
=================================================