[mod_python] (servlet) download files with req.sendfile

Nicolas Lehuen nicolas at lehuen.com
Wed Jul 14 10:40:24 EDT 2004

You should make sure that you send a proper Content-Type header before
calling sendfile. A curl -i on
http://pytsts2.codezone.ath.cx/dwn69?dwn=teste.tgz shows that you return a
text/plain MIME type, which is not correct. Plus, the HTML page is appended
to the end of the TGZ file.
As for the filename problem, I'm not sure, but I think the problem can be
solved with a Content-Disposition header, though it is a bit unreliable. See
Nicolas Lehuen


De : mod_python-bounces at modpython.org
[mailto:mod_python-bounces at modpython.org] De la part de Sharky @ Code Zone
Envoyé : mercredi 14 juillet 2004 03:44
À : mod_python mailing list
Objet : [mod_python] (servlet) download files with req.sendfile


    I have a test mod_python.servlet in http://pytsts2.codezone.ath.cx/dwn69
and don't know how to explain because my pour english but i will go try  8-)

    When i use req.sendfile('filename') my browser (Mozila) don't know the
file type and name for download the file. It uses script filename. But if i
download the file directly, my browser download fine and know the download
filename and type.

    What are missing from my code? What i'm doing wrong?


PS.: Sorry my n00b questions 8-) 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://modpython.org/pipermail/mod_python/attachments/20040714/ee56d1f5/attachment.html

More information about the Mod_python mailing list