set content-range header so boto knows this is a ranged response

This commit is contained in:
Konstantinos Koukopoulos 2015-02-10 19:15:10 +02:00
parent 418a6a118e
commit 261328d449
2 changed files with 3 additions and 0 deletions

View File

@ -245,6 +245,8 @@ class ResponseObject(_TemplateEnvironmentMixin):
return 400, headers, ""
if begin < 0 or end > length or begin > min(end, length):
return 416, headers, ""
headers['content-range'] = "bytes {0}-{1}/{2}".format(
begin, end, length)
return 206, headers, response_content[begin:end]
def key_response(self, request, full_url, headers):

View File

@ -704,3 +704,4 @@ def test_ranged_get():
key.get_contents_as_string(headers={'Range': 'bytes=45-55'}).should.equal(b'0' * 5 + b'1' * 5)
key.get_contents_as_string(headers={'Range': 'bytes=45-'}).should.equal(b'0' * 5 + b'1' * 50)
key.get_contents_as_string(headers={'Range': 'bytes=-55'}).should.equal(b'0' * 5 + b'1' * 50)
key.size.should.equal(100)