Revision bfa0341f
b/snf-pithos-app/pithos/api/test/objects.py | ||
---|---|---|
658 | 658 |
r = self.put(url, data=data, HTTP_ETAG='123') |
659 | 659 |
self.assertEqual(r.status_code, 422) |
660 | 660 |
|
661 |
def test_upload_if_none_match(self): |
|
662 |
cname = self.container |
|
663 |
oname = get_random_name() |
|
664 |
data = get_random_data() |
|
665 |
url = join_urls(self.pithos_path, self.user, cname, oname) |
|
666 |
r = self.put(url, data=data, HTTP_IF_NONE_MATCH='*') |
|
667 |
self.assertEqual(r.status_code, 201) |
|
668 |
|
|
669 |
r = self.get(url) |
|
670 |
self.assertEqual(r.status_code, 200) |
|
671 |
self.assertEqual(r.content, data) |
|
672 |
self.assertTrue('ETag' in r) |
|
673 |
etag = r['ETag'] |
|
674 |
|
|
675 |
url = join_urls(self.pithos_path, self.user, cname, oname) |
|
676 |
r = self.put(url, data=data, HTTP_IF_NONE_MATCH=etag) |
|
677 |
self.assertEqual(r.status_code, 412) |
|
678 |
|
|
661 | 679 |
# def test_chunked_transfer(self): |
662 | 680 |
# cname = self.container |
663 | 681 |
# oname = '/%s' % get_random_name() |
b/snf-pithos-app/pithos/api/util.py | ||
---|---|---|
438 | 438 |
def validate_matching_preconditions(request, meta): |
439 | 439 |
"""Check that the ETag conforms with the preconditions set.""" |
440 | 440 |
|
441 |
etag = meta['hash'] if not UPDATE_MD5 else meta['checksum'] |
|
442 |
if not etag: |
|
443 |
etag = None |
|
441 |
etag = meta.get('hash') if not UPDATE_MD5 else meta.get('checksum') |
|
444 | 442 |
|
445 | 443 |
if_match = request.META.get('HTTP_IF_MATCH') |
446 | 444 |
if if_match is not None: |
Also available in: Unified diff