          self.assertEquals(None, req2)
  
      def test_ajax_exemption(self):
          """
          Check the AJAX requests are automatically exempted.
          """
          req = self._get_POST_session_request()
          req.META['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
          req2 = CsrfMiddleware().process_view(req, self.get_view(), (), {})
          self.assertEquals(None, req2)
 
</s> remove         resp_content = resp.content
 </s> add 	resp_content = resp.content # needed because process_response modifies resp </s> remove         resp_content = resp.content
 </s> add 	resp_content = resp.content # needed because process_response modifies resp </s> remove You don't have to worry about doing this for most AJAX views. Any request sent
with "X-Requested-With: XMLHttpRequest" is automatically exempt. (See the next
section.)
 </s> add Like the middleware itself, the ``csrf_exempt`` decorator is composed
of two parts: a ``csrf_view_exempt`` decorator and a
``csrf_response_exempt`` decorator, found in the same module.  These
disable the view protection mechanism (``CsrfViewMiddleware``) and the
response post-processing (``CsrfResponseMiddleware``) respectively.
They can be used individually if required.

You don't have to worry about doing this for most AJAX views. Any
request sent with "X-Requested-With: XMLHttpRequest" is automatically
exempt. (See the next section.) </s> remove         resp_content = resp.content
 </s> add 	resp_content = resp.content # needed because process_response modifies resp
        Check that AJAX requests are automatically exempted.
          self.assertEquals(None, req2)
  
      def test_ajax_exemption(self):
          """
        Check that AJAX requests are automatically exempted.
          """
          req = self._get_POST_session_request()
          req.META['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
          req2 = CsrfMiddleware().process_view(req, self.get_view(), (), {})
          self.assertEquals(None, req2)
keep keep keep keep replace keep keep keep keep keep
 Made CSRF middleware skip post-processing for 'csrf_exempt' decorated views.

This commit also decomposes the decorator into two decorators which can be
used separately, adds some tests, updates docs and fixes some code comments.



git-svn-id: http://code.djangoproject.com/svn/django/trunk@9815 bcc190cf-cafb-0310-a4f2-bffc1f526a37 
django/contrib/csrf/tests.py