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

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


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

Modified Files:
      Tag: zope-2_3-branch
	HTTPRangeSupport.py 
Log Message:
Merge of byte range fix for the benefit of Zope.org.


=== Zope/lib/python/ZPublisher/HTTPRangeSupport.py 1.6.70.1 => 1.6.70.2 ===
--- Zope/lib/python/ZPublisher/HTTPRangeSupport.py:1.6.70.1	Sat Jul 13 17:14:24 2002
+++ Zope/lib/python/ZPublisher/HTTPRangeSupport.py	Wed Aug 21 17:44:13 2002
@@ -168,12 +168,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
 
     """
 
@@ -188,31 +186,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.