Created
September 9, 2012 01:22
-
-
Save dbishop/3681877 to your computer and use it in GitHub Desktop.
This patch to webob.byterange fixes "Range: bytes=-17" for Content-Length < 17 (eg. 10 in my tests).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/test/functional/tests.py b/test/functional/tests.py | |
index dd589e6..cd734ac 100644 | |
--- a/test/functional/tests.py | |
+++ b/test/functional/tests.py | |
@@ -1147,6 +1147,13 @@ class TestFile(Base): | |
hdrs = {'Range': '0-4'} | |
self.assert_(file.read(hdrs=hdrs) == data, range_string) | |
+ # "If the entity is shorter than the specified suffix-length, the | |
+ # entire entity-body is used." | |
+ range_string = 'bytes=-%d' % (file_length + 10) | |
+ hdrs = {'Range': range_string} | |
+ self.assert_(file.read(hdrs=hdrs) == data, range_string) | |
+ | |
+ | |
def testRangedGetsWithLWSinHeader(self): | |
#Skip this test until webob 1.2 can tolerate LWS in Range header. | |
from webob.byterange import Range |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
swiftstack@saio:~/swift/swift/obj$ diff -u /usr/share/pyshared/webob/byterange.py.orig /usr/share/pyshared/webob/byterange.py | |
--- /usr/share/pyshared/webob/byterange.py.orig 2012-09-07 16:48:30.996446789 -0700 | |
+++ /usr/share/pyshared/webob/byterange.py 2012-09-07 17:00:40.188476542 -0700 | |
@@ -36,7 +36,7 @@ | |
if end is None: | |
end = length | |
if start < 0: | |
- start += length | |
+ start = max(0, start + length) | |
if _is_content_range_valid(start, end, length): | |
stop = min(end, length) | |
return (start, stop) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment