[mod_python] sendfile problems with IE

Mark Norley m_norley_newsgroups at yahoo.co.uk
Wed Nov 1 05:02:57 EST 2006


Hi Colin
Thanks for all the info...you were right, the problem was due to some
temporary cache-control headers I'd set in an .htaccess file further up the
directory tree. Got rid of the headers and now it works fine in all three
browsers.
Thanks again!
Mark

-----Original Message-----
From: Colin Bean [mailto:ccbean at gmail.com] 
Sent: 01 November 2006 00:19
To: Mark Norley
Cc: mod_python at modpython.org
Subject: Re: [mod_python] sendfile problems with IE

Hi Mark,

Here's a thread that might deal with the same problems (in this case getting
IE to correctly display generated pdfs):
http://modpython.org/pipermail/mod_python/2006-October/022341.html

And I just realized that I sent a message in reply to this and didn't
re: the list (crap!).  My response is quoted in the reply here,
though:
http://modpython.org/pipermail/mod_python/2006-October/022348.html

I don't know if any of this will actually apply to what you're doing, but in
the PDF example IE was behaving strangely if the cache-control
header was set at all.   Doesn't look like you're setting it in the
code you provided, but there are some cases where mod_python will set it on
its own (for instance, when you're using sessions or cookies).
Is your code a complete handler, or does it get called in the context of a
larger site?

If it is something with the headers, a lightweight http proxy (I like
webscarab) is a nice way be able to look at the headers exactly as they are
being sent to the client.  You can also use it to verify that the content is
being sent completely.  However you want to do it, it might be helpful to
determine exactly what headers are being set.

The only other thing I can think of is that I usually put quotes around the
filename part of the content-disposition header
('attachment;filename="taggedhits.xls"').  I don't know if this causes IE to
break or not, but it might be worth trying.

Hopefully some of this helps...

-Colin

On 10/31/06, Mark Norley <m_norley_newsgroups at yahoo.co.uk> wrote:
> Hello
>
> Hope this list can save me again ;-)
> This bit of code works fine in Firefox and Netscape but IE doesn't like
it:
>
> def handler(req):
>     req.content_type = "application/vnd.ms-excel"
>     req.set_content_length(os.path.getsize(ROOT+'\\taggedhits.xls'))
>     req.headers_out["Content-Disposition"] = "attachment; 
> filename=taggedhits.xls"
>     req.sendfile(ROOT+"\\taggedhits.xls")
>     return apache.OK
>
> With IE the File Download dialogue looks strange. IE thinks the 
> filename is filehandler_py rather than taggedhits.xls:
>
> Name: filehandler_py
> Type: Microsoft Excel Worksheet, 13.5 KB
> From: 'mysite'
>
> filehandler.py is the name of the script for starters, not the file I 
> want to download, and why has IE swapped the dot for an underscore?
>
> On pressing Save I get:
> Internet Explorer cannot download filehandler.py from 'mysite'.
> Internet Explorer was not able to open this internet site. The 
> requested site is either unavailable or cannot be found. Please try again
later.
>
> Does anyone know what I need to do for IE to recognise the file? I'm 
> thinking I'm missing a header field or something.
>
> Cheers
> Mark
>
> Win XP SP2
> Python 2.4.2
> Apache 2.2.2
> Mod_python 3.2.10
> Firefox 1.5.0.7
> Netscape 7.2
> IE 6
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.409 / Virus Database: 268.13.20/508 - Release Date: 
> 31/10/06
>
>
> Send instant messages to your online friends 
> http://uk.messenger.yahoo.com 
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.13.20/508 - Release Date: 31/10/06
 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.13.20/508 - Release Date: 31/10/06
 

Send instant messages to your online friends http://uk.messenger.yahoo.com 


More information about the Mod_python mailing list