[Twisted-web] Setting the twcgi header?
Alex Newby
alex at alexnewby.com
Tue Jul 13 19:52:10 MDT 2004
Date: Mon, 12 Jul 2004 10:15:27 -0400
From: Donovan Preston <dp at ulaluma.com>
Subject: Re: [Twisted-web] Setting the twcgi header?
To: "Discussion of twisted.web, Nevow, and Woven"
<twisted-web at twistedmatrix.com>
>>
>> class PythonCGI(twcgi.FilteredScript):
>> filter = '/usr/local/bin/python'
>>
>> I wish to set the following header for my PythonCGI:
>>
>> print "Content-type: application/x-shockwave-flash\n\n"
>>
>> But, instead the script renders:
>>
>> Connection: close
>> Content-type: text/html
>> Server: TwistedWeb/1.3.0rc1
>>
>> How do I change the header?
Override render_GET, and then call setHeader('content-type',
application/x-shockwave-flash'). There may also be some sort of
attribute you can set which will cause FilteredScript to do this for
you, I'm not sure. Examine the source code.
dp
-----
Thanks Donovan,
This is an uncommon case. I'm trying to use Ming's output method in a
pythonCGI. Having traced the method of choice within twisted
'protocols.http.Request.setHeader', until I finally thought to peek at
the source code for 'newow.appserver.NevowRequest' (NevowSite is
powering my site)
class NevowRequest:
def process(self):
#I think it may be defaulting here
self.setHeader('content-type', "text/html")
Not sure though.
---------------------------------
Sincerely,
Alex Newby
E-mail: alex at alexnewby.com
Website: http://www.alexnewby.com
More information about the Twisted-web
mailing list