mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #27083 -- Added support for weak ETags.
This commit is contained in:
committed by
Tim Graham
parent
e7abb5ba86
commit
4ef0e019b7
@@ -208,14 +208,19 @@ class TestUtilsHttp(unittest.TestCase):
|
||||
|
||||
class ETagProcessingTests(unittest.TestCase):
|
||||
def test_parsing(self):
|
||||
etags = http.parse_etags(r'"", "etag", "e\"t\"ag", "e\\tag", W/"weak"')
|
||||
self.assertEqual(etags, ['', 'etag', 'e"t"ag', r'e\tag', 'weak'])
|
||||
self.assertEqual(
|
||||
http.parse_etags(r'"" , "etag", "e\\tag", W/"weak"'),
|
||||
['""', '"etag"', r'"e\\tag"', 'W/"weak"']
|
||||
)
|
||||
self.assertEqual(http.parse_etags('*'), ['*'])
|
||||
|
||||
# Ignore RFC 2616 ETags that are invalid according to RFC 7232.
|
||||
self.assertEqual(http.parse_etags(r'"etag", "e\"t\"ag"'), ['"etag"'])
|
||||
|
||||
def test_quoting(self):
|
||||
original_etag = r'e\t"ag'
|
||||
quoted_etag = http.quote_etag(original_etag)
|
||||
self.assertEqual(quoted_etag, r'"e\\t\"ag"')
|
||||
self.assertEqual(http.unquote_etag(quoted_etag), original_etag)
|
||||
self.assertEqual(http.quote_etag('etag'), '"etag"') # unquoted
|
||||
self.assertEqual(http.quote_etag('"etag"'), '"etag"') # quoted
|
||||
self.assertEqual(http.quote_etag('W/"etag"'), 'W/"etag"') # quoted, weak
|
||||
|
||||
|
||||
class HttpDateProcessingTests(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user