From 35a99d2faf867dba1285a81a9baba6d1feeb71f9 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Thu, 10 Sep 2015 16:24:22 +0200 Subject: start reraising exceptions properly --- libmproxy/protocol/http.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libmproxy/protocol/http.py') diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py index 212bec96..70c5095d 100644 --- a/libmproxy/protocol/http.py +++ b/libmproxy/protocol/http.py @@ -1,4 +1,6 @@ from __future__ import (absolute_import, print_function, division) +import six +import sys from netlib import tcp from netlib.http import http1, HttpErrorConnClosed, HttpError, Headers @@ -62,7 +64,7 @@ class _StreamingHttpLayer(_HttpLayer): if response.body == CONTENT_MISSING: raise HttpError(502, "Cannot assemble flow with CONTENT_MISSING") self.send_response_headers(response) - self.send_response_body(response, response.body) + self.send_response_body(response, [response.body]) class Http1Layer(_StreamingHttpLayer): @@ -381,9 +383,9 @@ class HttpLayer(Layer): except NetLibError: pass if isinstance(e, ProtocolException): - raise e + six.reraise(*sys.exc_info()) else: - raise ProtocolException("Error in HTTP connection: %s" % repr(e), e) + six.reraise(ProtocolException, ProtocolException("Error in HTTP connection: %s" % repr(e), e), sys.exc_info()[2]) finally: flow.live = False -- cgit v1.2.3