diff options
author | Ian Bicking <ian@ianbicking.org> | 2005-07-26 17:12:18 +0000 |
---|---|---|
committer | Ian Bicking <ian@ianbicking.org> | 2005-07-26 17:12:18 +0000 |
commit | a73406e660251b21dc385d69a634cc942e4ab9ec (patch) | |
tree | 0dd56dc2387aaa410ab3a9be5c36d6f2edf75507 | |
parent | 172deed0c71ae2b4e8fbc3fcbf82776e6c3727ec (diff) | |
download | paste-git-a73406e660251b21dc385d69a634cc942e4ab9ec.tar.gz |
Be more careful about whether headers were really sent, if an error occurs in the start_response call itself
-rw-r--r-- | paste/errormiddleware.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/paste/errormiddleware.py b/paste/errormiddleware.py index cf8936b..83c4ba8 100644 --- a/paste/errormiddleware.py +++ b/paste/errormiddleware.py @@ -65,19 +65,24 @@ class ErrorMiddleware(object): environ['paste.throw_errors'] = True def detect_start_response(status, headers, exc_info=None): - started.append(True) - return start_response(status, headers, exc_info) - + try: + return start_response(status, headers, exc_info) + except: + raise + else: + started.append(True) try: __traceback_supplement__ = Supplement, self, environ app_iter = self.application(environ, detect_start_response) return self.catching_iter(app_iter, environ) except: + exc_info = sys.exc_info() if not started: start_response('500 Internal Server Error', - [('content-type', 'text/html')]) + [('content-type', 'text/html')], + exc_info) # @@: it would be nice to deal with bad content types here - response = self.exception_handler(sys.exc_info(), environ) + response = self.exception_handler(exc_info, environ) return [response] def catching_iter(self, app_iter, environ): |