示例#1
0
 def process_response(self, request, response):
     """
     This removes the ``Vary: Cookie`` header prior to running the standard
     Django ``UpdateCacheMiddleware.process_response()`` and adds the
     header back after caching so that in-browser caches are aware to vary
     the cache on cookies.
     """
     drop_vary_headers(response, ['Cookie'])
     response = super(PatchedVaryUpdateCacheMiddleware, self).process_response(request, response)
     patch_vary_headers(response, ['Cookie'])
     return response
示例#2
0
 def process_response(self, request, response):
     """
     This removes the ``Vary: Cookie`` header prior to running the standard
     Django ``UpdateCacheMiddleware.process_response()`` and adds the
     header back after caching so that in-browser caches are aware to vary
     the cache on cookies.
     """
     drop_vary_headers(response, ['Cookie'])
     response = super(PatchedVaryUpdateCacheMiddleware, self).process_response(request, response)
     patch_vary_headers(response, ['Cookie'])
     return response
示例#3
0
    def test_drop_vary_headers(self):
        response = HttpResponse()

        self.assertFalse(response.has_header('Vary'))
        patch_vary_headers(response, ['Cookie'])
        self.assertTrue(response.has_header('Vary'))
        self.assertEqual(response['Vary'], 'Cookie')
        patch_vary_headers(response, ['Nomnomnom'])
        self.assertEqual(response['Vary'], 'Cookie, Nomnomnom')
        drop_vary_headers(response, ['Cookie'])
        self.assertEqual(response['Vary'], 'Nomnomnom')
        drop_vary_headers(response, ['Nomnomnom'])
        self.assertFalse(response.has_header('Vary'))
示例#4
0
    def test_drop_vary_headers(self):
        response = HttpResponse()

        self.assertFalse(response.has_header('Vary'))
        patch_vary_headers(response, ['Cookie'])
        self.assertTrue(response.has_header('Vary'))
        self.assertEqual(response['Vary'], 'Cookie')
        patch_vary_headers(response, ['Nomnomnom'])
        self.assertEqual(response['Vary'], 'Cookie, Nomnomnom')
        drop_vary_headers(response, ['Cookie'])
        self.assertEqual(response['Vary'], 'Nomnomnom')
        drop_vary_headers(response, ['Nomnomnom'])
        self.assertFalse(response.has_header('Vary'))