softlayer / softlayer-object-storage-python

SoftLayer Object Storage Python Client
Other
19 stars 30 forks source link

Fixed support for 'Range' header #6

Closed SecurityForUs closed 11 years ago

SecurityForUs commented 11 years ago

While I don't think the fix is 100% 'Pythonic', it reflects the fact that there are multiple scenarios for 'Range' header: http://docs.openstack.org/trunk/openstack-object-storage/developer/content/retrieve-object.html

I wrote a testing function that simulates this to demonstrate how it works in comparison to the above link:

>>> def tester(size=0,offset=0):
...     if size > 0:
...         if not offset:
...             print "bytes=-%d" % (size-1)
...         else:
...             print "bytes=%d-%d" % (offset, (offset+size) - 1)
...     else:
...         print "bytes=%d-" % (offset)
... 
>>> tester(offset=32)
bytes=32-
>>> tester(offset=5)
bytes=5-
>>> tester(5)
bytes=-4
>>> tester(5,10)
bytes=10-14
CrackerJackMack commented 11 years ago

Either the diff viewer is messed up or you used tabs?

SecurityForUs commented 11 years ago

im not sure what you mean. the commits were loading fine for me via github

SecurityForUs commented 11 years ago

I used tabs in some of them apparently, sorry about that. I fixed it w/ spaces now and it should be fine.

SecurityForUs commented 11 years ago

Didn't catch that one, sorry about that.

sudorandom commented 11 years ago

I'm going to close this pull request not because it wasn't good, but because there was one additional case that we found and wanted to support as well. If you look at the code and at the tests that we added, you can see why. Thanks for your input. We really appreciate it.

https://github.com/softlayer/softlayer-object-storage-python/commit/748353038499dba62b943065471d5f7ea941c4e6