boto/boto — Issue #520: S3 get_contents_as_string() returns empty string after InvalidRange error
Author: vsekhar
Created: 2012-01-26 07:21:56+00:00
State: open

After requesting a range that cannot be satisfied, subsequent (valid) range requests return the empty string. Requesting the valid range again produces the correct result.

Steps to reproduce in 2.1.1:

import boto
c = boto.connect_s3()
b = c.get_bucket('mybucket')
k = b.get_key('small_file') # say, 5 bytes

k.get_contents_as_string(headers={'Range': 'bytes=%s-%s' % (0, 100)}) # returns '12345'
k.get_contents_as_string(headers={'Range': 'bytes=%s-%s' % (80, 100)}) # raises 416 Requested Range Not Satisfiable
k.get_contents_as_string(headers={'Range': 'bytes=%s-%s' % (0, 100)}) # ** returns '' instead of '12345' **
k.get_contents_as_string(headers={'Range': 'bytes=%s-%s' % (0, 100)}) # returns '12345'