diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-05-07 21:34:01 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-05-07 21:34:01 +1200 |
commit | d42fdc4ff6a228f098e9e12a2aeec9737748dfcc (patch) | |
tree | c8f0c9bbe942ed3f014ae5541470b919df449478 /libmproxy/wsgi.py | |
parent | 116fcfcf7a744c98328bc9df87e9fa5490b66ae7 (diff) | |
download | mitmproxy-d42fdc4ff6a228f098e9e12a2aeec9737748dfcc.tar.gz mitmproxy-d42fdc4ff6a228f098e9e12a2aeec9737748dfcc.tar.bz2 mitmproxy-d42fdc4ff6a228f098e9e12a2aeec9737748dfcc.zip |
Include a formatted exception in WSGI error page.
Diffstat (limited to 'libmproxy/wsgi.py')
-rw-r--r-- | libmproxy/wsgi.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libmproxy/wsgi.py b/libmproxy/wsgi.py index 0865ee72..ce0367fb 100644 --- a/libmproxy/wsgi.py +++ b/libmproxy/wsgi.py @@ -1,4 +1,4 @@ -import cStringIO, urllib, time, sys +import cStringIO, urllib, time, sys, traceback import version, flow def date_time_string(): @@ -55,7 +55,7 @@ class WSGIAdaptor: environ[key] = value return environ - def error_page(self, soc, headers_sent): + def error_page(self, soc, headers_sent, s): """ Make a best-effort attempt to write an error page. If headers are already sent, we just bung the error into the page. @@ -63,10 +63,11 @@ class WSGIAdaptor: c = """ <html> <h1>Internal Server Error</h1> + <pre>%s"</pre> </html> - """ + """%s if not headers_sent: - soc.write("HTTP/1.1 500 Internal Server Error%s\r\n") + soc.write("HTTP/1.1 500 Internal Server Error\r\n") soc.write("Content-Type: text/html\r\n") soc.write("Content-Length: %s\r\n"%len(c)) soc.write("\r\n") @@ -115,7 +116,8 @@ class WSGIAdaptor: write("") except Exception, v: try: - self.error_page(soc, state["headers_sent"]) + s = traceback.format_exc() + self.error_page(soc, state["headers_sent"], s) # begin nocover except Exception, v: pass |