how to change response code in CGIHTTPServer.py

D

Daniel

Hello,

Python 2.5.2
WinXP

I'm using CGIHTTPServer.py and want to return a response code of 400
with a message in the event that the cgi script fails for some
reason. I notice that
run_cgi(self):
executes this line of code,
self.send_response(200, "Script output follows")
which overwrites any headers that I print in my cgi. Is there some
way to modify the response code without having to override
CGIHTTPServer.py?

Thanks,
 
J

Jeff McNeil

Hello,

Python 2.5.2
WinXP

I'm using CGIHTTPServer.py and want to return a response code of 400
with a message in the event that the cgi script fails for some
reason.  I notice that
run_cgi(self):
executes this line of code,
self.send_response(200, "Script output follows")
which overwrites any headers that I print in my cgi.  Is there some
way to modify the response code without having to override
CGIHTTPServer.py?

Thanks,
....
Note that status code 200 is sent prior to execution of a CGI script,
so
scripts cannot send other status codes such as 302 (redirect).
....
It sets that header before it even fires off the CGI script and just
pipes the following response to the client.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,785
Messages
2,569,624
Members
45,319
Latest member
LorenFlann

Latest Threads

Top