From 5b7e19a77e12ffac2e699d2dc92f96f90114ee01 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 18 Aug 2014 00:55:30 +0200 Subject: [PATCH] fix #327 --- libmproxy/protocol/http.py | 19 +++++++++++++++++++ libmproxy/proxy/connection.py | 20 ++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py index 21d2c7ea0..b8eca7d8c 100644 --- a/libmproxy/protocol/http.py +++ b/libmproxy/protocol/http.py @@ -261,6 +261,9 @@ class HTTPRequest(HTTPMessage): f._load_state(state) return f + def __repr__(self): + return "".format(self._assemble_first_line(self.form_in)[:-9]) + @classmethod def from_stream(cls, rfile, include_body=True, body_size_limit=None): """ @@ -632,6 +635,14 @@ class HTTPResponse(HTTPMessage): f._load_state(state) return f + def __repr__(self): + return "".format( + code=self.code, + msg=self.msg, + contenttype=self.headers.get_first("content-type", "?"), + size=utils.pretty_size(len(self.content)) + ) + @classmethod def from_stream(cls, rfile, request_method, include_body=True, body_size_limit=None): """ @@ -803,6 +814,14 @@ class HTTPFlow(Flow): f._load_state(state) return f + def __repr__(self): + s = "".format( + ssl="[ssl] " if self.ssl_established else "", + host=self.address.host, + port=self.address.port + ) + _stateobject_attributes = dict( timestamp_start=float, timestamp_end=float, @@ -76,6 +83,19 @@ class ServerConnection(tcp.TCPClient, stateobject.SimpleStateObject): self.timestamp_tcp_setup = None self.timestamp_ssl_setup = None + def __repr__(self): + if self.ssl_established and self.sni: + ssl = "[ssl: {0}] ".format(self.sni) + elif self.ssl_established: + ssl = "[ssl] " + else: + ssl = "" + return "".format( + ssl=ssl, + host=self.address.host, + port=self.address.port + ) + _stateobject_attributes = dict( state=list, peername=tuple,