diff options
author | ianb <devnull@localhost> | 2007-03-20 00:13:08 +0000 |
---|---|---|
committer | ianb <devnull@localhost> | 2007-03-20 00:13:08 +0000 |
commit | 8b693dacf8777548af3cc6f6613ca39d7f3c137c (patch) | |
tree | f3708c26187a3020b866793727d5b1ee2098e588 /paste/httpserver.py | |
parent | 2ffa29e30ac84af25b83990079262c44a15db64b (diff) | |
download | paste-8b693dacf8777548af3cc6f6613ca39d7f3c137c.tar.gz |
Give a better error when start_response isn't called; give a Content-Length so that the connection is closed properly on error
Diffstat (limited to 'paste/httpserver.py')
-rwxr-xr-x | paste/httpserver.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/paste/httpserver.py b/paste/httpserver.py index d2d0c16..8f70cc4 100755 --- a/paste/httpserver.py +++ b/paste/httpserver.py @@ -120,6 +120,9 @@ class WSGIHandlerMixin: Write a chunk of the output stream; send headers if they have not already been sent. """ + if not self.wsgi_headers_sent and not self.wsgi_curr_headers: + raise RuntimeError( + "Content returned before start_response called") if not self.wsgi_headers_sent: self.wsgi_headers_sent = True (status, headers) = self.wsgi_curr_headers @@ -284,8 +287,11 @@ class WSGIHandlerMixin: return except: if not self.wsgi_headers_sent: - self.wsgi_curr_headers = ('500 Internal Server Error', - [('Content-type', 'text/plain')]) + error_msg = "Internal Server Error\n" + self.wsgi_curr_headers = ( + '500 Internal Server Error', + [('Content-type', 'text/plain'), + ('Content-length', str(len(error_msg)))]) self.wsgi_write_chunk("Internal Server Error\n") raise |