[Zope-Checkins] CVS: Zope/lib/python/OFS/tests - testRanges.py:1.9.2.2
Martijn Pieters
mj@zope.com
Thu, 6 Dec 2001 18:34:19 -0500
Update of /cvs-repository/Zope/lib/python/OFS/tests
In directory cvs.zope.org:/tmp/cvs-serv13910/lib/python/OFS/tests
Modified Files:
Tag: Zope-2_5-branch
testRanges.py
Log Message:
*sigh* Netscape 4 and before implement a draft version of the HTTP Range spec,
and so does MSIE 3, apparently. For these clients, fix the resulting multipart
cotent type.
This fixes PDF downloads on these clients.
=== Zope/lib/python/OFS/tests/testRanges.py 1.9.2.1 => 1.9.2.2 ===
`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
@@ -179,6 +179,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,
@@ -187,9 +190,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.' % (
@@ -303,6 +307,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()