[Twisted-web] Content-disposition and static.File

tarjei tarjei at nu.no
Fri Aug 29 04:17:22 EDT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I'm using static.File to return various pdf files to the user. The files
are stored using the document ID, but I want the browser to return the
correct filename.

Usually I've done this(in PHP) by adding 'Content-Disposition:
attachement;filename=foo.pdf', but I'm not getting this to work with
twisted. Basicly I do:

def locateChild(self, ctx):
   request = inevow.IRequest(ctx)
   request.setHeader("content-disposition" ,"attachment;filename=foo.pdf")

   return static.File(self.path_to_file)

This works well (except I do not get to define the filename) if I do not
add the content-disposition header, but when I do that twisted just
explodes into an exception.

My question is: Is this a bug or a missing feature?

Also, am I doing something else wrong by setting the header before
returning another page?

Kind regards,
Tarjei
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIt7CSYVRKCnSvzfIRApY+AKCcJF3V1F55eVQlbgNJ9mgnICjzewCcCgIr
j6is0/veiuYvWuA2k9OVq1s=
=Aet3
-----END PGP SIGNATURE-----



More information about the Twisted-web mailing list