[Zope-Checkins] CVS: Zope/lib/python/ZPublisher - HTTPRangeSupport.py:1.6.8.1
Martijn Pieters
mj@zope.com
Wed, 21 Aug 2002 16:51:19 -0400
Update of /cvs-repository/Zope/lib/python/ZPublisher
In directory cvs.zope.org:/tmp/cvs-serv9798/ZPublisher
Modified Files:
Tag: Zope-2_5-branch
HTTPRangeSupport.py
Log Message:
Fix for Zope Collector issue #530 (http://collector.zope.org/Zope/530);
Adobe Acrobat for windows hangs on optimized byte ranges.
- Improve file byte range serving to allow arbitrary order byte ranges.
- Drop optimizations of byte ranges altogether; rename the method to
expandRanges. This means we'll have to swallow loosing the small bandwidth
wins we got from merging overlapping ranges (which was allowed under the
RFC).
- Update the tests to follow the changes.
=== Zope/lib/python/ZPublisher/HTTPRangeSupport.py 1.6 => 1.6.8.1 ===
--- Zope/lib/python/ZPublisher/HTTPRangeSupport.py:1.6 Wed Jan 2 10:56:04 2002
+++ Zope/lib/python/ZPublisher/HTTPRangeSupport.py Wed Aug 21 16:51:18 2002
@@ -96,12 +96,10 @@
return ranges
-def optimizeRanges(ranges, size):
- """Optimize Range sets, given those sets and the length of the resource.
+def expandRanges(ranges, size):
+ """Expand Range sets, given those sets and the length of the resource.
- Optimisation is done by first expanding relative start values and open
- ends, then sorting and combining overlapping ranges. We also remove
- unsatisfiable ranges (where the start lies beyond the size of the resource).
+ Expansion means relative start values and open ends
"""
@@ -116,31 +114,7 @@
if start < size:
add((start, end))
- ranges = expanded
- ranges.sort()
- ranges.reverse()
- optimized = []
- add = optimized.append
- start, end = ranges.pop()
-
- while ranges:
- nextstart, nextend = ranges.pop()
- # If the next range overlaps
- if nextstart < end:
- # If it falls within the current range, discard
- if nextend <= end:
- continue
-
- # Overlap, adjust end
- end = nextend
- else:
- add((start, end))
- start, end = nextstart, nextend
-
- # Add the remaining optimized range
- add((start, end))
-
- return optimized
+ return expanded
class HTTPRangeInterface(Interface.Base):
"""Objects implementing this Interface support the HTTP Range header.