changeset 132:65a49831b539

Use HTTP status code 500 for error pages.
author Allan Saddi <allan@saddi.com>
date Tue, 11 Jan 2011 10:43:06 -0800
parents 9d18e87f004f
children d75c21b506bb
files ChangeLog flup/server/ajp_base.py flup/server/fcgi_base.py flup/server/scgi_base.py
diffstat 4 files changed, 17 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/ChangeLog	Thu Oct 14 16:33:20 2010 -0700
     1.2 +++ b/ChangeLog	Tue Jan 11 10:43:06 2011 -0800
     1.3 @@ -1,3 +1,8 @@
     1.4 +2011-01-11  Allan Saddi  <allan@saddi.com>
     1.5 +
     1.6 +	* Use HTTP status code 500 for error pages. Thanks to
     1.7 +	  Yohann Gabory for pointing out this issue and providing a patch.
     1.8 +
     1.9  2010-10-14  Allan Saddi  <allan@saddi.com>
    1.10  
    1.11  	* Don't try to restore signal handlers if they weren't installed in
     2.1 --- a/flup/server/ajp_base.py	Thu Oct 14 16:33:20 2010 -0700
     2.2 +++ b/flup/server/ajp_base.py	Tue Jan 11 10:43:06 2011 -0800
     2.3 @@ -960,7 +960,8 @@
     2.4          all errors should be caught at the application level.
     2.5          """
     2.6          if self.debug:
     2.7 -            request.startResponse(200, 'OK', [('Content-Type', 'text/html')])
     2.8 +            request.startResponse(500, 'Internal Server Error',
     2.9 +                                  [('Content-Type', 'text/html')])
    2.10              import cgitb
    2.11              request.write(cgitb.html(sys.exc_info()))
    2.12          else:
    2.13 @@ -972,5 +973,6 @@
    2.14  <p>An unhandled exception was thrown by the application.</p>
    2.15  </body></html>
    2.16  """
    2.17 -            request.startResponse(200, 'OK', [('Content-Type', 'text/html')])
    2.18 +            request.startResponse(500, 'Internal Server Error',
    2.19 +                                  [('Content-Type', 'text/html')])
    2.20              request.write(errorpage)
     3.1 --- a/flup/server/fcgi_base.py	Thu Oct 14 16:33:20 2010 -0700
     3.2 +++ b/flup/server/fcgi_base.py	Tue Jan 11 10:43:06 2011 -0800
     3.3 @@ -1214,7 +1214,8 @@
     3.4          """
     3.5          if self.debug:
     3.6              import cgitb
     3.7 -            req.stdout.write('Content-Type: text/html\r\n\r\n' +
     3.8 +            req.stdout.write('Status: 500 Internal Server Error\r\n' +
     3.9 +                             'Content-Type: text/html\r\n\r\n' +
    3.10                               cgitb.html(sys.exc_info()))
    3.11          else:
    3.12              errorpage = """<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    3.13 @@ -1225,5 +1226,6 @@
    3.14  <p>An unhandled exception was thrown by the application.</p>
    3.15  </body></html>
    3.16  """
    3.17 -            req.stdout.write('Content-Type: text/html\r\n\r\n' +
    3.18 +            req.stdout.write('Status: 500 Internal Server Error\r\n' +
    3.19 +                             'Content-Type: text/html\r\n\r\n' +
    3.20                               errorpage)
     4.1 --- a/flup/server/scgi_base.py	Thu Oct 14 16:33:20 2010 -0700
     4.2 +++ b/flup/server/scgi_base.py	Tue Jan 11 10:43:06 2011 -0800
     4.3 @@ -550,7 +550,8 @@
     4.4          """
     4.5          if self.debug:
     4.6              import cgitb
     4.7 -            request.stdout.write('Content-Type: text/html\r\n\r\n' +
     4.8 +            request.stdout.write('Status: 500 Internal Server Error\r\n' +
     4.9 +                                 'Content-Type: text/html\r\n\r\n' +
    4.10                                   cgitb.html(sys.exc_info()))
    4.11          else:
    4.12              errorpage = """<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    4.13 @@ -561,5 +562,6 @@
    4.14  <p>An unhandled exception was thrown by the application.</p>
    4.15  </body></html>
    4.16  """
    4.17 -            request.stdout.write('Content-Type: text/html\r\n\r\n' +
    4.18 +            request.stdout.write('Status: 500 Internal Server Error\r\n' +
    4.19 +                                 'Content-Type: text/html\r\n\r\n' +
    4.20                                   errorpage)