Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
0d670939
Commit
0d670939
authored
Dec 04, 2001
by
Martijn Pieters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge HTTP Ranges fix from Zope 2.4 branch
parent
d1596f3e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
14 deletions
+13
-14
lib/python/OFS/tests/testRanges.py
lib/python/OFS/tests/testRanges.py
+7
-7
lib/python/ZPublisher/HTTPRangeSupport.py
lib/python/ZPublisher/HTTPRangeSupport.py
+4
-5
lib/python/ZPublisher/tests/testHTTPRangeSupport.py
lib/python/ZPublisher/tests/testHTTPRangeSupport.py
+2
-2
No files found.
lib/python/OFS/tests/testRanges.py
View file @
0d670939
...
...
@@ -274,9 +274,6 @@ class TestRequestRange(unittest.TestCase):
# A satisfiable and an unsatisfiable range
self
.
expectSingleRange
(
'-0,3-23'
,
3
,
24
)
def
testAdjacentRanges
(
self
):
self
.
expectSingleRange
(
'21-25,10-20'
,
10
,
26
)
def
testEndOverflow
(
self
):
l
=
len
(
self
.
data
)
start
,
end
=
l
-
10
,
l
+
10
...
...
@@ -301,6 +298,9 @@ class TestRequestRange(unittest.TestCase):
self
.
expectSingleRange
(
range
,
start
,
len
(
self
.
data
))
# Multiple ranges
def
testAdjacentRanges
(
self
):
self
.
expectMultipleRanges
(
'21-25,10-20'
,
[(
10
,
21
),
(
21
,
26
)])
def
testMultipleRanges
(
self
):
self
.
expectMultipleRanges
(
'3-7,10-15'
,
[(
3
,
8
),
(
10
,
16
)])
...
...
@@ -320,10 +320,10 @@ class TestRequestRange(unittest.TestCase):
def
testIllegalIfRange
(
self
):
# We assume that an illegal if-range is to be ignored, just like an
# illegal if-modified since.
self
.
expectSingleRange
(
'21-25,10-2
0
'
,
10
,
26
,
if_range
=
'garbage'
)
self
.
expectSingleRange
(
'21-25,10-2
1
'
,
10
,
26
,
if_range
=
'garbage'
)
def
testEqualIfRangeDate
(
self
):
self
.
expectSingleRange
(
'21-25,10-2
0
'
,
10
,
26
,
self
.
expectSingleRange
(
'21-25,10-2
1
'
,
10
,
26
,
if_range
=
self
.
createLastModifiedDate
())
def
testIsModifiedIfRangeDate
(
self
):
...
...
@@ -331,11 +331,11 @@ class TestRequestRange(unittest.TestCase):
if_range
=
self
.
createLastModifiedDate
(
offset
=-
100
))
def
testIsNotModifiedIfRangeDate
(
self
):
self
.
expectSingleRange
(
'21-25,10-2
0
'
,
10
,
26
,
self
.
expectSingleRange
(
'21-25,10-2
1
'
,
10
,
26
,
if_range
=
self
.
createLastModifiedDate
(
offset
=
100
))
def
testEqualIfRangeEtag
(
self
):
self
.
expectSingleRange
(
'21-25,10-2
0
'
,
10
,
26
,
self
.
expectSingleRange
(
'21-25,10-2
1
'
,
10
,
26
,
if_range
=
self
.
file
.
http__etag
())
def
testNotEqualIfRangeEtag
(
self
):
...
...
lib/python/ZPublisher/HTTPRangeSupport.py
View file @
0d670939
...
...
@@ -100,9 +100,8 @@ def optimizeRanges(ranges, size):
"""Optimize 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 or adjacent ranges. We also
remove unsatisfiable ranges (where the start lies beyond the size of the
resource).
ends, then sorting and combining overlapping ranges. We also remove
unsatisfiable ranges (where the start lies beyond the size of the resource).
"""
...
...
@@ -126,8 +125,8 @@ def optimizeRanges(ranges, size):
while ranges:
nextstart, nextend = ranges.pop()
# If the next range overlaps
or is adjacent
if nextstart <
=
end:
# If the next range overlaps
if nextstart < end:
# If it falls within the current range, discard
if nextend <= end:
continue
...
...
lib/python/ZPublisher/tests/testHTTPRangeSupport.py
View file @
0d670939
...
...
@@ -113,10 +113,10 @@ class TestOptimizeRanges(unittest.TestCase):
def
testAdjacentInOrder
(
self
):
self
.
expectSets
([(
1
,
10
),
(
10
,
20
),
(
25
,
50
)],
5000
,
[(
1
,
20
),
(
25
,
50
)])
[(
1
,
10
),
(
10
,
20
),
(
25
,
50
)])
def
testAdjacentOutOfOrder
(
self
):
self
.
expectSets
([(
-
5
,
None
),
(
40
,
45
)],
50
,
[(
40
,
50
)])
self
.
expectSets
([(
-
5
,
None
),
(
40
,
45
)],
50
,
[(
40
,
45
),
(
45
,
50
)])
def
testOverLapAndOverflow
(
self
):
# Note that one endpoint lies beyond the end.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment