[Twisted-Python] Static file filenames and MIME types...

Stuart Hungerford stuart.hungerford at anu.edu.au
Tue Jun 10 21:33:14 EDT 2003

Hi all,

I think these questions show my ignorance of HTTP request headers
as much has anything, but:

In a twisted.web based application I'm returning a file in a resource
render() call via the twisted.web.static.File class.

If I've understood right, it's possible to specify the MIME type
of the file in the static.file constructor call.  Between this
setting and a request.setHeader('Content-Type', 'foo') call which
one takes priority?

I think I still need to set a request.setHeader('Content-Length')
to the size of the file?  (Conveniently available via the
.getFileSize() method of static.file)?

If the person at the other end wants to save the file, what's the
best way to suggest the filename, is it a setHeader of
'Content-Location' or does static.File take care of that?



:: Stuart Hungerford (stuart.hungerford at anu.edu.au)
:: ANU Internet Futures Group

More information about the Twisted-Python mailing list