Example #1
0
 def _inner(*args, **kwargs):
     """
     Alters the response.
     """
     response = func(*args, **kwargs)
     remove_headers_from_response(response, *headers)
     return response
    def test_removes_intended_headers(self):
        fake_request = HttpRequest()

        fake_response = HttpResponse()
        fake_response['Vary'] = 'Cookie'
        fake_response['Accept-Encoding'] = 'gzip'
        remove_headers_from_response(fake_response, 'Vary')

        result = self.middleware.process_response(fake_request, fake_response)
        self.assertNotIn('Vary', result)
        self.assertEquals('gzip', result['Accept-Encoding'])
    def test_doesnt_barf_removing_nonexistent_headers(self):
        fake_request = HttpRequest()

        fake_response = HttpResponse()
        fake_response['Vary'] = 'Cookie'
        fake_response['Accept-Encoding'] = 'gzip'
        remove_headers_from_response(fake_response, 'Vary', 'FakeHeaderWeeee')

        result = self.middleware.process_response(fake_request, fake_response)
        self.assertNotIn('Vary', result)
        self.assertEquals('gzip', result['Accept-Encoding'])