[Zope] problem opening pdf-files with firefox in LocalFS folders on Zope

Dieter Maurer dieter at handshake.de
Fri May 5 16:18:41 EDT 2006

Marinussen, M.J. (Ria) wrote at 2006-5-4 09:52 +0200:
>I've got Zope 2.8.5 installed with LocalFS version LocalFS-1-3-andreas
>on Solaris (SunOs 5.8, I'm not sure which version number of solaris that
>When I place pdf-files in the LocalFS directories, sometimes they open
>correctly, but most of the time they open as text-file when using

A bug in "LocalFS".

In our local copy, I fixed it this way (in "LocalFS/StreamingFile.py"):

class StreamingFile(File):
        # DM 2005-11-07
        #  funny that we should not need a "Content-Type" header
        #  when the file is sufficiently small?
        if RESPONSE is not None:
            # DM 2005-11-18: support for 'if_modified_since' and range requests
            if self._if_modified_since_request_handler(REQUEST, RESPONSE):
                # we were able to handle this by returning a 304
                return ''
            if self._range_request_handler(REQUEST, RESPONSE):
                # we served a chunk of content in response to a range request.
                return ''
	    RESPONSE.setHeader('Content-Type', self.content_type)
            #DM 2005-11-17: 'Last-Modified' support
            # DM 2005-11-18: support for range requests
	    RESPONSE.setHeader('Accept-Ranges', 'bytes')
	threshold = 2 << 16 # 128 kb
	if self.size < threshold or RESPONSE is None:
		f = open(self._local_path, 'rb')
		return f.read()
	    RESPONSE.setHeader('Content-Length', self.size)
            # DM 2005-11-07: moved outside the "if"
	    #RESPONSE.setHeader('Content-Type', self.content_type)
	    return filestream_iterator(self._local_path, 'rb')

The fix also provides "if-modified-since" and "if-ranges".

>With other browsers (Internet Explorer, Opera) this problem does not

They ignore the (wrong) "Content-Type" and look on the filename extension.


More information about the Zope mailing list