Changeset 6696
- Timestamp:
- 11/18/07 21:12:19 (11 months ago)
- Files:
-
- django/trunk/django/utils/cache.py (modified) (3 diffs)
- django/trunk/tests/regressiontests/cache/tests.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/utils/cache.py
r6634 r6696 71 71 response['Cache-Control'] = cc 72 72 73 vary_delim_re = re.compile(r',\s*')74 75 73 def patch_response_headers(response, cache_timeout=None): 76 74 """ … … 112 110 vary = [] 113 111 if response.has_header('Vary'): 114 vary = vary_delim_re.split(response['Vary'])112 vary = cc_delim_re.split(response['Vary']) 115 113 oldheaders = dict([(el.lower(), 1) for el in vary]) 116 114 for newheader in newheaders: … … 170 168 if response.has_header('Vary'): 171 169 headerlist = ['HTTP_'+header.upper().replace('-', '_') 172 for header in vary_delim_re.split(response['Vary'])]170 for header in cc_delim_re.split(response['Vary'])] 173 171 cache.set(cache_key, headerlist, cache_timeout) 174 172 return _generate_cache_key(request, headerlist, key_prefix) django/trunk/tests/regressiontests/cache/tests.py
r6572 r6696 4 4 # Uses whatever cache backend is set in the test settings file. 5 5 6 import time, unittest 7 6 8 from django.core.cache import cache 7 import time, unittest 9 from django.utils.cache import patch_vary_headers 10 from django.http import HttpResponse 8 11 9 12 # functions/classes for complex data type tests … … 88 91 self.assertEqual(cache.get(key), value) 89 92 93 94 class CacheUtils(unittest.TestCase): 95 """TestCase for django.utils.cache functions.""" 96 97 def test_patch_vary_headers(self): 98 headers = ( 99 # Initial vary, new headers, resulting vary. 100 (None, ('Accept-Encoding',), 'Accept-Encoding'), 101 ('Accept-Encoding', ('accept-encoding',), 'Accept-Encoding'), 102 ('Accept-Encoding', ('ACCEPT-ENCODING',), 'Accept-Encoding'), 103 ('Cookie', ('Accept-Encoding',), 'Cookie, Accept-Encoding'), 104 ('Cookie, Accept-Encoding', ('Accept-Encoding',), 'Cookie, Accept-Encoding'), 105 ('Cookie, Accept-Encoding', ('Accept-Encoding', 'cookie'), 'Cookie, Accept-Encoding'), 106 (None, ('Accept-Encoding', 'COOKIE'), 'Accept-Encoding, COOKIE'), 107 ('Cookie, Accept-Encoding', ('Accept-Encoding', 'cookie'), 'Cookie, Accept-Encoding'), 108 ('Cookie , Accept-Encoding', ('Accept-Encoding', 'cookie'), 'Cookie, Accept-Encoding'), 109 ) 110 for initial_vary, newheaders, resulting_vary in headers: 111 response = HttpResponse() 112 if initial_vary is not None: 113 response['Vary'] = initial_vary 114 patch_vary_headers(response, newheaders) 115 self.assertEqual(response['Vary'], resulting_vary) 116 117 90 118 if __name__ == '__main__': 91 119 unittest.main()
