Issue Details (XML | Word | Printable)

Key: MODPYTHON-167
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Graham Dumpleton
Reporter: Graham Dumpleton
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
mod_python

If PythonDebug is On and error occurs, status is 200 when it should really be 500.

Created: 24/Apr/06 01:48 PM   Updated: 17/Apr/07 10:44 AM
Return to search
Component/s: core
Affects Version/s: 3.1.4, 3.2.8
Fix Version/s: 3.3.1

Time Tracking:
Not Specified

Resolution Date: 24/Apr/06 04:39 PM


 Description  « Hide
If PythonDebug is Off and an uncaught exception occurs in Python, the details of that exception will be logged in the Apache error log file. At the same time a 500 (HTTP_INTERNAL_SERVER_ERROR) response is returned to the client with whatever the configured default 500 error response message is for Apache.

If PythonDebug is On, the details are still logged to the error log, but the details of the exception will also be formatted and returned in the response to the client. In returning this response though, the HTTP status code is being returned as 200 (HTTP_OK) rather than the more correct 500 (HTTP_INTERNAL_SERVER_ERROR).

By wrongly returning 200 rather than 500, one could theoretically run up against problems like the response being cached, or if client was a non interactive application, it may think it was an entirely valid response and not flag in some way that it was actually an error.

The change to fix this in the code are as details in following patch. Note that returning 500 will still result in the message being displayed in a web browser, so for its intended purpose of displaying a traceback to a client, it will still work as required.

Index: lib/python/mod_python/apache.py
===================================================================
--- lib/python/mod_python/apache.py (revision 396453)
+++ lib/python/mod_python/apache.py (working copy)
@@ -533,6 +533,7 @@
                     return HTTP_INTERNAL_SERVER_ERROR
                 else:
                     # write to client
+ req.status = HTTP_INTERNAL_SERVER_ERROR
                     req.content_type = 'text/html'
 
                     s = '\n<pre>\nMod_python error: "%s %s"\n\n' % (phase, hname)


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Graham Dumpleton made changes - 24/Apr/06 01:48 PM
Field Original Value New Value
Status Open [ 1 ] In Progress [ 3 ]
Graham Dumpleton made changes - 24/Apr/06 04:39 PM
Fix Version/s 3.3 [ 12310101 ]
Resolution Fixed [ 1 ]
Status In Progress [ 3 ] Resolved [ 5 ]
Graham Dumpleton made changes - 17/Apr/07 10:44 AM
Status Resolved [ 5 ] Closed [ 6 ]