SOLVED! (was Re: [Zope] Content-Disposition is driving me batty)
On Thursday 17 August 2006 10:55 am, David H wrote: > I had similar problems too. This seems to work with IE: > theFile=open( self.pdfpath,'rb') > result = theFile.read() > > RESPONSE.setHeader('Content-Type','application/pdf') > RESPONSE.setHeader("Content-Disposition","filename=report.pdf") > RESPONSE.setHeader('Content-Length',len(result)) > RESPONSE.write(result) Sending the "Content-Length" header fixed the problem. PDFs now appear inline and with their expected contents. I haven't diffed the code between 2.8 and 2.9, but I'm guessing that Zope used to send that header by default but no longer does. -- Kirk Strauser The Day Companies ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Content-Disposition is driving me batty
On Thursday 17 August 2006 1:28 pm, Dieter Maurer wrote: > Your PDF file appears to be small. It was pretty dinky earlier (a single line of text). > I am also surprised that in your earlier post you returned > the "File" object itself. I would rather expect > "str(fileObject.data)". Without looking at the source, I'm guessing that ExtFile.__repr__ just calls str() anyway. -- Kirk Strauser The Day Companies ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Content-Disposition is driving me batty
Kirk Strauser wrote at 2006-8-16 17:28 -0500: >I have a Python script that transmits a file to the user. An excerpt: > >if not skipctypeheader: ># Set the content type if one is defined for the file >ctype = file.getProperty('content_type', d=None) >if ctype: >RESPONSE.setHeader('Content-Type', ctype) > >RESPONSE.setHeader('Content-Disposition', 'inline; filename=%s' % filename) > >< HTTP/1.1 200 OK >< Date: Wed, 16 Aug 2006 22:26:11 GMT >< Server: Zope/(Zope 2.9.3-, python 2.4.3, freebsd6) ZServer/1.1 >< Content-Length: 1742 Your PDF file appears to be small. I am also surprised that in your earlier post you returned the "File" object itself. I would rather expect "str(fileObject.data)". -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Content-Disposition is driving me batty
On Thursday 17 August 2006 11:24 am, Brian Sullivan wrote: > It looks like you have changed to remove the Content-Disposition header? > > Now it comes up "inline" (I guess the default?). No, it's still there (and still set to "inline"). I did, however, follow David H's advice to add the Content-Length header. Preliminary tests are very promising. -- Kirk Strauser The Day Companies ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Content-Disposition is driving me batty
On 8/17/06, Kirk Strauser <[EMAIL PROTECTED]> wrote: On Thursday 17 August 2006 11:02 am, Brian Sullivan wrote: > OK -- that seems to be more what I would call normal. I see the page > with "This is a test" in Adobe reader -- but also a page/tab is > created that is blank. Is that the problem? Nope - customers are actually getting a single blank page and nothing else. We could live with a blank tab if that was the only problem. It looks like you have changed to remove the Content-Disposition header? Now it comes up "inline" (I guess the default?). ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Content-Disposition is driving me batty
On Thursday 17 August 2006 11:02 am, Brian Sullivan wrote: > OK -- that seems to be more what I would call normal. I see the page > with "This is a test" in Adobe reader -- but also a page/tab is > created that is blank. Is that the problem? Nope - customers are actually getting a single blank page and nothing else. We could live with a blank tab if that was the only problem. -- Kirk Strauser The Day Companies ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Content-Disposition is driving me batty
On 8/17/06, Kirk Strauser <[EMAIL PROTECTED]> wrote: Nuts. I was trying to generate a "clean" PDF for testing purposes but looks like it didn't work. I re-uploaded the test file (same URL) with Times New Roman and embedded fonts. OK -- that seems to be more what I would call normal. I see the page with "This is a test" in Adobe reader -- but also a page/tab is created that is blank. Is that the problem? ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Content-Disposition is driving me batty
Andreas Jung wrote: --On 16. August 2006 17:28:00 -0500 Kirk Strauser <[EMAIL PROTECTED]> wrote: I have a Python script that transmits a file to the user. An excerpt: if not skipctypeheader: # Set the content type if one is defined for the file ctype = file.getProperty('content_type', d=None) if ctype: RESPONSE.setHeader('Content-Type', ctype) RESPONSE.setHeader('Content-Disposition', 'inline; filename=%s' % filename) I remember having had similar problems with IE and downloading files. In general we use only content-disposition: attachment for IE vs. content-disposition: inline for all other browsers. After that change we haven't had any bug reports from IE users. -aj I had similar problems too. This seems to work with IE: theFile=open( self.pdfpath,'rb') result = theFile.read() RESPONSE.setHeader('Content-Type','application/pdf') RESPONSE.setHeader("Content-Disposition","filename=report.pdf") RESPONSE.setHeader('Content-Length',len(result)) RESPONSE.write(result) David ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Content-Disposition is driving me batty
On Thursday 17 August 2006 9:54 am, Brian Sullivan wrote: > I am running IE7 beta 3 -- on my machine the pdf file seems to load -- > so no content disposition problem but there are messages about missing > fonts from the PDF reader *7.0.8 btw) -- no real information is > displayed so I am guessing this is "abnormal" by your definition. Nuts. I was trying to generate a "clean" PDF for testing purposes but looks like it didn't work. I re-uploaded the test file (same URL) with Times New Roman and embedded fonts. -- Kirk Strauser The Day Companies ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Content-Disposition is driving me batty
Would some IE users please let me know whether they can view this PDF normally? http://web2.xrsnet.com/publicstore/download?filename=print.pdf&password=foo Any speculation about what might be causing this is extremely welcome. I'm *not* looking forward to rolling back to 2.8.x (and Python 2.3) at this point. I am running IE7 beta 3 -- on my machine the pdf file seems to load -- so no content disposition problem but there are messages about missing fonts from the PDF reader *7.0.8 btw) -- no real information is displayed so I am guessing this is "abnormal" by your definition. ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Content-Disposition is driving me batty
--On 16. August 2006 17:28:00 -0500 Kirk Strauser <[EMAIL PROTECTED]> wrote: I have a Python script that transmits a file to the user. An excerpt: if not skipctypeheader: # Set the content type if one is defined for the file ctype = file.getProperty('content_type', d=None) if ctype: RESPONSE.setHeader('Content-Type', ctype) RESPONSE.setHeader('Content-Disposition', 'inline; filename=%s' % filename) I remember having had similar problems with IE and downloading files. In general we use only content-disposition: attachment for IE vs. content-disposition: inline for all other browsers. After that change we haven't had any bug reports from IE users. -aj pgpfUJO6oNDzC.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )