[Zope-Checkins] CVS: Zope/lib/python/OFS/tests - testRanges.py:1.2.22.3
Martijn Pieters
mj@zope.com
Tue, 18 Dec 2001 12:43:14 -0500
Update of /cvs-repository/Zope/lib/python/OFS/tests
In directory cvs.zope.org:/tmp/cvs-serv6598/lib/python/OFS/tests
Modified Files:
Tag: Zope-2_4-branch
testRanges.py
Log Message:
MErge draft-spec ranges fix from 2.5 branch.
=== Zope/lib/python/OFS/tests/testRanges.py 1.2.22.2 => 1.2.22.3 ===
`self.data[start:end]`, `body`))
- def expectMultipleRanges(self, range, sets,
+ def expectMultipleRanges(self, range, sets, draft=0,
rangeParse=re.compile('bytes\s*(\d+)-(\d+)/(\d+)')):
req = self.app.REQUEST
rsp = req.RESPONSE
@@ -251,6 +251,9 @@
# Add headers
req.environ['HTTP_RANGE'] = 'bytes=%s' % range
+ if draft:
+ req.environ['HTTP_REQUEST_RANGE'] = 'bytes=%s' % range
+
body = self.doGET(req, rsp)
self.failUnless(rsp.getStatus() == 206,
@@ -259,9 +262,10 @@
'The Content-Range header should not be set!')
ct = string.split(rsp.getHeader('content-type'), ';')[0]
- self.failIf(ct != 'multipart/byteranges',
- "Incorrect Content-Type set. Expected 'multipart/byteranges', "
- "got %s" % ct)
+ draftprefix = draft and 'x-' or ''
+ self.failIf(ct != 'multipart/%sbyteranges' % draftprefix,
+ "Incorrect Content-Type set. Expected 'multipart/%sbyteranges', "
+ "got %s" % (draftprefix, ct))
if rsp.getHeader('content-length'):
self.failIf(rsp.getHeader('content-length') != len(body),
'Incorrect Content-Length is set! Expected %d, got %d.' % (
@@ -374,6 +378,9 @@
def testMultipleRanges(self):
self.expectMultipleRanges('3-7,10-15', [(3, 8), (10, 16)])
+
+ def testMultipleRangesDraft(self):
+ self.expectMultipleRanges('3-7,10-15', [(3, 8), (10, 16)], draft=1)
def testMultipleRangesBigFile(self):
self.uploadBigFile()