aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/protocol/http.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-09-12 17:10:38 +0200
committerMaximilian Hils <git@maximilianhils.com>2015-09-12 17:10:38 +0200
commiteb2264e91a7fef4170eade4bc6af9c0c4fe9694a (patch)
tree4facdc5a2f7b625a41c90652b9c105fd019e537a /libmproxy/protocol/http.py
parent049d253a83e18116340670cb86528b4ac1d3b215 (diff)
downloadmitmproxy-eb2264e91a7fef4170eade4bc6af9c0c4fe9694a.tar.gz
mitmproxy-eb2264e91a7fef4170eade4bc6af9c0c4fe9694a.tar.bz2
mitmproxy-eb2264e91a7fef4170eade4bc6af9c0c4fe9694a.zip
improve display of non-ascii contents
fixes #283
Diffstat (limited to 'libmproxy/protocol/http.py')
-rw-r--r--libmproxy/protocol/http.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py
index 3a415320..230f2be9 100644
--- a/libmproxy/protocol/http.py
+++ b/libmproxy/protocol/http.py
@@ -1,6 +1,7 @@
from __future__ import (absolute_import, print_function, division)
import itertools
import sys
+import traceback
import six
@@ -384,9 +385,13 @@ class HttpLayer(Layer):
return
except (HttpErrorConnClosed, NetLibError, HttpError, ProtocolException) as e:
+ error_propagated = False
if flow.request and not flow.response:
- flow.error = Error(repr(e))
+ flow.error = Error(str(e))
self.channel.ask("error", flow)
+ self.log(traceback.format_exc(), "debug")
+ error_propagated = True
+
try:
self.send_response(make_error_response(
getattr(e, "code", 502),
@@ -394,10 +399,12 @@ class HttpLayer(Layer):
))
except NetLibError:
pass
- if isinstance(e, ProtocolException):
- six.reraise(ProtocolException, e, sys.exc_info()[2])
- else:
- six.reraise(ProtocolException, ProtocolException("Error in HTTP connection: %s" % repr(e)), sys.exc_info()[2])
+
+ if not error_propagated:
+ if isinstance(e, ProtocolException):
+ six.reraise(ProtocolException, e, sys.exc_info()[2])
+ else:
+ six.reraise(ProtocolException, ProtocolException("Error in HTTP connection: %s" % repr(e)), sys.exc_info()[2])
finally:
flow.live = False