Hi Dieter, Thanks for your quick response and solution. It's a great relief to have it working OK for Firefox too! With regards, Ria
-----Original Message----- From: Dieter Maurer [mailto:dieter@handshake.de] Sent: 05 May 2006 22:19 To: Marinussen, M.J. (Ria) Cc: zope@zope.org Subject: Re: [Zope] problem opening pdf-files with firefox in LocalFS folders onZope
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 is...)
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 Firefox.
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 RESPONSE.setHeader( 'Last-Modified', rfc1123_date(stat(self._local_path)[8]) ) # 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: try: f = open(self._local_path, 'rb') return f.read() finally: f.close() else: 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 occur.
They ignore the (wrong) "Content-Type" and look on the filename extension.
-- Dieter