mirror of
https://github.com/django/django.git
synced 2025-07-24 13:44:32 +00:00
Fixed #28104 -- Prevented condition decorator from setting ETag/Last-Modified headers for non-safe requests.
This commit is contained in:
parent
268a646353
commit
37c9b81ebc
3 changed files with 30 additions and 12 deletions
|
@ -19,10 +19,14 @@ class ConditionalGet(SimpleTestCase):
|
|||
def assertFullResponse(self, response, check_last_modified=True, check_etag=True):
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.content, FULL_RESPONSE.encode())
|
||||
if check_last_modified:
|
||||
self.assertEqual(response['Last-Modified'], LAST_MODIFIED_STR)
|
||||
if check_etag:
|
||||
self.assertEqual(response['ETag'], ETAG)
|
||||
if response.request['REQUEST_METHOD'] in ('GET', 'HEAD'):
|
||||
if check_last_modified:
|
||||
self.assertEqual(response['Last-Modified'], LAST_MODIFIED_STR)
|
||||
if check_etag:
|
||||
self.assertEqual(response['ETag'], ETAG)
|
||||
else:
|
||||
self.assertNotIn('Last-Modified', response)
|
||||
self.assertNotIn('ETag', response)
|
||||
|
||||
def assertNotModified(self, response):
|
||||
self.assertEqual(response.status_code, 304)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue