[Zope-Checkins] CVS: Zope/lib/python/OFS - Image.py:1.133.2.1

Martijn Pieters mj@zope.com
Thu, 6 Dec 2001 18:34:49 -0500


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

Modified Files:
      Tag: Zope-2_5-branch
	Image.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/Image.py 1.133 => 1.133.2.1 ===
         # HTTP Range header handling
         range = REQUEST.get_header('Range', None)
+        request_range = REQUEST.get_header('Request-Range', None)
+        if request_range is not None:
+            # Netscape 2 through 4 and MSIE 3 implement a draft version
+            # Later on, we need to serve a different mime-type as well.
+            range = request_range
         if_range = REQUEST.get_header('If-Range', None)
         if range is not None:
             ranges = HTTPRangeSupport.parseRange(range)
@@ -284,12 +289,17 @@
                             end - start)
                             
                     
+                    # Some clients implement an earlier draft of the spec, they
+                    # will only accept x-byteranges.
+                    draftprefix = (request_range is not None) and 'x-' or ''
+
                     RESPONSE.setHeader('Content-Length', size)
                     RESPONSE.setHeader('Accept-Ranges', 'bytes')
                     RESPONSE.setHeader('Last-Modified',
                         rfc1123_date(self._p_mtime))
                     RESPONSE.setHeader('Content-Type',
-                        'multipart/byteranges; boundary=%s' % boundary)
+                        'multipart/%sbyteranges; boundary=%s' % (
+                            draftprefix, boundary))
                     RESPONSE.setStatus(206) # Partial content
 
                     pos = 0