diff options
| author | Anton Novosyolov <anton.novosyolov@gmail.com> | 2014-10-21 00:22:02 +0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-10-21 11:13:29 -0400 |
| commit | 9f1202c166093160c8796dc570d675415fdf5bf8 (patch) | |
| tree | b111ae875765077ac209dd2fce039560472b1279 | |
| parent | 0e16c3e3cd61b119e067b369f3ff928a2e4045b4 (diff) | |
Fixed #23695 -- Made condition decorator work for HEAD requests without ETag.
| -rw-r--r-- | django/views/decorators/http.py | 2 | ||||
| -rw-r--r-- | tests/conditional_processing/tests.py | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/django/views/decorators/http.py b/django/views/decorators/http.py index df4e165066..bfb68295d1 100644 --- a/django/views/decorators/http.py +++ b/django/views/decorators/http.py @@ -139,7 +139,7 @@ def condition(etag_func=None, last_modified_func=None): } ) response = HttpResponse(status=412) - elif (not if_none_match and request.method == "GET" and + elif (not if_none_match and request.method in ("GET", "HEAD") and res_last_modified and if_modified_since and res_last_modified <= if_modified_since): response = HttpResponseNotModified() diff --git a/tests/conditional_processing/tests.py b/tests/conditional_processing/tests.py index 934ca5c4ec..72dd1dd48c 100644 --- a/tests/conditional_processing/tests.py +++ b/tests/conditional_processing/tests.py @@ -124,6 +124,11 @@ class ConditionalGet(TestCase): response = self.client.get('/condition/last_modified2/') self.assertFullResponse(response, check_etag=False) + def test_single_condition_head(self): + self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = LAST_MODIFIED_STR + response = self.client.head('/condition/') + self.assertNotModified(response) + def test_invalid_etag(self): self.client.defaults['HTTP_IF_NONE_MATCH'] = r'"\"' response = self.client.get('/condition/etag/') |
