[mod_python] Setting HTTP response status line

Roger Binns rogerb at rogerbinns.com
Sun May 6 16:57:07 EDT 2007


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

I'm trying to set the response status line, and failing.

def handler(req):
   raise apache.SERVER_RETURN, (400, "You must supply a foo")

This is with the mod_python on Ubuntu feisty (3.2.10).  From the code in
apache.py, it sets req.status with the text message although the doc
says that is an integer field.

However the http client always receives standard text (eg 'Bad Request'
for code 400).

The PythonDebug option is also confusing.  If I turn it on, then
responses go back as 200 OK with the body of tracebacks etc, whereas
with it off then you get 500 Internal Server Error with no traceback
type information.

It seems to me that if you want to return anything other than success
that Apache goes to great lengths to obliterate whatever it is that you
were trying to send back and replaces it with its own canned
information, hence the behaviour of PythonDebug.  Is there any way
around this?

Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGPkEjmOOfHg372QQRAtuxAKDLsTPlKUZEbhGBS7DBAo0lgFd+8ACfRY5B
Kr0KeQjYPQEAc90GEY5dnbM=
=Rm72
-----END PGP SIGNATURE-----


More information about the Mod_python mailing list