diff options
Diffstat (limited to 'libmproxy')
| -rw-r--r-- | libmproxy/flow.py | 6 | ||||
| -rw-r--r-- | libmproxy/proxy.py | 5 | 
2 files changed, 8 insertions, 3 deletions
| diff --git a/libmproxy/flow.py b/libmproxy/flow.py index b33707ca..ff5c3cf1 100644 --- a/libmproxy/flow.py +++ b/libmproxy/flow.py @@ -606,10 +606,10 @@ class Response(HTTPMsg):              timestamp: Seconds since the epoch      """ -    def __init__(self, request, code, msg, headers, content, der_cert, timestamp=None): +    def __init__(self, request, httpversion, code, msg, headers, content, der_cert, timestamp=None):          assert isinstance(headers, ODictCaseless)          self.request = request -        self.code, self.msg = code, msg +        self.httpversion, self.code, self.msg = httpversion, code, msg          self.headers, self.content = headers, content          self.der_cert = der_cert          self.timestamp = timestamp or utils.timestamp() @@ -692,6 +692,7 @@ class Response(HTTPMsg):      def _get_state(self):          return dict( +            httpversion = self.httpversion,              code = self.code,              msg = self.msg,              headers = self.headers._get_state(), @@ -704,6 +705,7 @@ class Response(HTTPMsg):      def _from_state(klass, request, state):          return klass(              request, +            state["httpversion"],              state["code"],              str(state["msg"]),              ODictCaseless._from_state(state["headers"]), diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index 3be20761..7698a61f 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -309,6 +309,9 @@ class ServerConnection:          if not len(parts) == 3:              raise ProxyError(502, "Invalid server response: %s."%line)          proto, code, msg = parts +        httpversion = parse_http_protocol(proto) +        if httpversion is None: +            raise ProxyError(502, "Invalid HTTP version: %s."%httpversion)          try:              code = int(code)          except ValueError: @@ -320,7 +323,7 @@ class ServerConnection:              content = ""          else:              content = read_http_body(self.rfile, self, headers, True, self.config.body_size_limit) -        return flow.Response(request, code, msg, headers, content, self.cert) +        return flow.Response(request, httpversion, code, msg, headers, content, self.cert)      def terminate(self):          try: | 
