websrv_lib: improve sending of internal error
bzr revid: p_christ@hol.gr-20100726093335-n8s6cpjmi2252myf
This commit is contained in:
@@ -169,6 +169,9 @@ class FixSendError:
|
||||
self.send_header('Connection', 'close')
|
||||
self.send_header('Content-Length', len(content) or 0)
|
||||
self.end_headers()
|
||||
if hasattr(self, '_flush'):
|
||||
self._flush()
|
||||
|
||||
if self.command != 'HEAD' and code >= 200 and code not in (204, 304):
|
||||
self.wfile.write(content)
|
||||
|
||||
@@ -232,11 +235,15 @@ class MultiHTTPHandler(FixSendError,BaseHTTPRequestHandler):
|
||||
method = getattr(fore, mname)
|
||||
try:
|
||||
method()
|
||||
except (AuthRejectedExc, AuthRequiredExc):
|
||||
raise
|
||||
except Exception, e:
|
||||
self.log_error("Could not run %s: %s" % (mname, e))
|
||||
fore.send_error(500, "Internal error")
|
||||
self._get_ignore_body(fore)
|
||||
self.send_error(500, "Internal error")
|
||||
# may not work if method has already sent data
|
||||
fore.close_connection = 1
|
||||
self.close_connection = 1
|
||||
if hasattr(fore, '_flush'):
|
||||
fore._flush()
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user