[mod_python] sendfile problems with IE

Colin Bean ccbean at gmail.com
Tue Oct 31 19:19:22 EST 2006

Hi Mark,

Here's a thread that might deal with the same problems (in this case
getting IE to correctly display generated pdfs):

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,

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...


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
> 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

More information about the Mod_python mailing list