[mod_python] http response code

Ricardo Rocha ricardo.rocha at cern.ch
Tue Aug 22 03:25:30 EDT 2006


Hi all.

I'm not really sure if this is a mod_python or apache question, but i'll 
give it a try anyway. My setup is Apache 2.0.55 with mod_python 3.2.

I've been looking for a way to send additional error messages along with 
the HTTP error codes. The first thing i did was to remove the default 
apache error messages by adding the following directives to the apache 
config:
ErrorDocument 400 " "
ErrorDocument 401 " "
ErrorDocument 404 " "
ErrorDocument 406 " "
ErrorDocument 409 " "
ErrorDocument 500 " "
ErrorDocument 501 " "

Then i was hoping that returning the proper HTTP code from the handler 
would do it... and it does, as long as i haven't written anything back 
to the client before.

If i do write something back inside the handler, if i try to return 
apache.HTTP_BAD_REQUEST (for example), it will always give a 200 HTTP_OK 
code back to the client, along with the response text.

Is there a way to overcome this and have both a response being written 
back and a specific HTTP code being returned?

Thanks in advance,
   Ricardo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2678 bytes
Desc: S/MIME Cryptographic Signature
Url : http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20060822/f63c3b91/smime.bin


More information about the Mod_python mailing list