[Zope-Checkins] CVS: Zope/lib/python/ZPublisher - HTTPRangeSupport.py:1.8

Martijn Pieters mj@zope.com
Wed, 21 Aug 2002 17:17:59 -0400


Update of /cvs-repository/Zope/lib/python/ZPublisher
In directory cvs.zope.org:/tmp/cvs-serv15554/lib/python/ZPublisher

Modified Files:
	HTTPRangeSupport.py 
Log Message:
Merge fix for Zope Collector issue #530 from 2.5 branch; do not optimize
byte ranges because Acrobat Reader for Windows chokes when overlapping
ranges have been merged.


=== Zope/lib/python/ZPublisher/HTTPRangeSupport.py 1.7 => 1.8 ===
--- Zope/lib/python/ZPublisher/HTTPRangeSupport.py:1.7	Wed Aug 14 18:09:40 2002
+++ Zope/lib/python/ZPublisher/HTTPRangeSupport.py	Wed Aug 21 17:17:59 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.