Code

Ticket #10581: 10581.diff

File 10581.diff, 1.5 KB (added by isagalaev, 5 years ago)

Patch

Line 
1=== modified file 'django/views/decorators/http.py'
2--- django/views/decorators/http.py     2009-03-22 10:17:44 +0000
3+++ django/views/decorators/http.py     2009-03-22 10:35:13 +0000
4@@ -75,7 +75,7 @@
5             if if_none_match or if_match:
6                 # There can be more than one ETag in the request, so we
7                 # consider the list of values.
8-                etags = parse_etags(if_none_match)
9+                etags = parse_etags(if_none_match or if_match)
10 
11             # Compute values (if any) for the requested resource.
12             if etag_func:
13
14=== modified file 'tests/regressiontests/conditional_processing/models.py'
15--- tests/regressiontests/conditional_processing/models.py      2009-03-22 07:58:29 +0000
16+++ tests/regressiontests/conditional_processing/models.py      2009-03-22 10:35:42 +0000
17@@ -50,6 +50,14 @@
18         response = self.client.get('/condition/')
19         self.assertNotModified(response)
20 
21+    def testIfMatch(self):
22+        self.client.defaults['HTTP_IF_MATCH'] = '"%s"' % ETAG
23+        response = self.client.put('/condition/etag/', {'data': ''})
24+        self.assertEquals(response.status_code, 200)
25+        self.client.defaults['HTTP_IF_MATCH'] = '"%s"' % EXPIRED_ETAG
26+        response = self.client.put('/condition/etag/', {'data': ''})
27+        self.assertEquals(response.status_code, 412)
28+
29     def testBothHeaders(self):
30         self.client.defaults['HTTP_IF_MODIFIED_SINCE'] = LAST_MODIFIED_STR
31         self.client.defaults['HTTP_IF_NONE_MATCH'] = '"%s"' % ETAG
32