[mod_python] http response code

Richard Lewis richardlewis at fastmail.co.uk
Tue Aug 22 04:31:21 EDT 2006


On Tuesday 22 August 2006 08:25, Ricardo Rocha wrote:
>
> Is there a way to overcome this and have both a response being written
> back and a specific HTTP code being returned?
>
Have you tried using the req.status member? If you're returning a status other 
than 200 and you also want to write content to the response stream, I think 
you're supposed to set the status before writing the content and then return 
the same status code after writing the content:

def handler(req):
  if req.unparsed_uri not in VALID_URIS:
    req.status = apache.HTTP_NOT_FOUND
    req.write(NOT_FOUND_ERROR_ESSAGE)
    return apache.HTTP_NOT_FOUND

Cheers,
Richard
-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Richard Lewis
Sonic Arts Research Archive
http://www.sara.uea.ac.uk/
JID: ironchicken at jabber.earth.li
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


More information about the Mod_python mailing list