Author: mtredinnick
Date: 2009-03-22 18:16:03 -0500 (Sun, 22 Mar 2009)
New Revision: 10116

Modified:
   django/trunk/django/views/decorators/http.py
   django/trunk/tests/regressiontests/conditional_processing/models.py
Log:
Fixed #10581 -- Fixed conditional handling of If-Match headers.

The conditional processing decorator from r10114 wasn't parsing ETags
from an If-Match header correctly. Patch from Ivan Sagalaev (who also
did most of the work in r10114, before I rewrote parts of it and added
bonus bugs, although I forgot to thank him there).

Modified: django/trunk/django/views/decorators/http.py
===================================================================
--- django/trunk/django/views/decorators/http.py        2009-03-22 16:13:06 UTC 
(rev 10115)
+++ django/trunk/django/views/decorators/http.py        2009-03-22 23:16:03 UTC 
(rev 10116)
@@ -75,7 +75,7 @@
             if if_none_match or if_match:
                 # There can be more than one ETag in the request, so we
                 # consider the list of values.
-                etags = parse_etags(if_none_match)
+                etags = parse_etags(if_none_match or if_match)
 
             # Compute values (if any) for the requested resource.
             if etag_func:

Modified: django/trunk/tests/regressiontests/conditional_processing/models.py
===================================================================
--- django/trunk/tests/regressiontests/conditional_processing/models.py 
2009-03-22 16:13:06 UTC (rev 10115)
+++ django/trunk/tests/regressiontests/conditional_processing/models.py 
2009-03-22 23:16:03 UTC (rev 10116)
@@ -50,6 +50,14 @@
         response = self.client.get('/condition/')
         self.assertNotModified(response)
 
+    def testIfMatch(self):
+        self.client.defaults['HTTP_IF_MATCH'] = '"%s"' % ETAG
+        response = self.client.put('/condition/etag/', {'data': ''})
+        self.assertEquals(response.status_code, 200)
+        self.client.defaults['HTTP_IF_MATCH'] = '"%s"' % EXPIRED_ETAG
+        response = self.client.put('/condition/etag/', {'data': ''})
+        self.assertEquals(response.status_code, 412)
+
     def testBothHeaders(self):
         self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = LAST_MODIFIED_STR
         self.client.defaults['HTTP_IF_NONE_MATCH'] = '"%s"' % ETAG


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to