Skip to content

Commit

Permalink
Fixed #10581 -- Fixed conditional handling of If-Match headers.
Browse files Browse the repository at this point in the history
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).

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10116 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
malcolmt committed Mar 22, 2009
1 parent 14b1609 commit 3bb6800
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django/views/decorators/http.py
Expand Up @@ -75,7 +75,7 @@ def inner(request, *args, **kwargs):
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:
Expand Down
8 changes: 8 additions & 0 deletions tests/regressiontests/conditional_processing/models.py
Expand Up @@ -50,6 +50,14 @@ def testIfNoneMatch(self):
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
Expand Down

0 comments on commit 3bb6800

Please sign in to comment.