Revision 6d1e6dce pithos/api/util.py
b/pithos/api/util.py | ||
---|---|---|
41 | 41 |
from django.http import HttpResponse |
42 | 42 |
from django.utils.http import http_date, parse_etags |
43 | 43 |
|
44 |
from pithos.api.compat import parse_http_date_safe |
|
44 |
from pithos.api.compat import parse_http_date_safe, parse_http_date
|
|
45 | 45 |
from pithos.api.faults import (Fault, NotModified, BadRequest, Unauthorized, ItemNotFound, |
46 | 46 |
LengthRequired, PreconditionFailed, RangeNotSatisfiable, |
47 | 47 |
ServiceUnavailable) |
... | ... | |
554 | 554 |
offset < 0 or offset >= size or |
555 | 555 |
offset + length > size] |
556 | 556 |
if len(check) > 0: |
557 |
raise RangeNotSatisfiable('Requested range exceeds object limits')
|
|
557 |
raise RangeNotSatisfiable('Requested range exceeds object limits') |
|
558 | 558 |
ret = 206 |
559 |
if_range = request.META.get('HTTP_IF_RANGE', '') |
|
560 |
if if_range and if_range.startswith('If-Range:'): |
|
561 |
if_range = if_range.split('If-Range:')[1] |
|
562 |
try: |
|
563 |
# modification time has passed instead |
|
564 |
last_modified = parse_http_date(if_range) |
|
565 |
if last_modified != meta['modified']: |
|
566 |
ranges = [(0, size)] |
|
567 |
ret = 200 |
|
568 |
except ValueError: |
|
569 |
if if_range != meta['hash']: |
|
570 |
ranges = [(0, size)] |
|
571 |
ret = 200 |
|
559 | 572 |
|
560 | 573 |
if ret == 206 and len(ranges) > 1: |
561 | 574 |
boundary = uuid.uuid4().hex |
Also available in: Unified diff