mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +00:00
fix #327
This commit is contained in:
parent
623cbd4e51
commit
5b7e19a77e
@ -261,6 +261,9 @@ class HTTPRequest(HTTPMessage):
|
||||
f._load_state(state)
|
||||
return f
|
||||
|
||||
def __repr__(self):
|
||||
return "<HTTPRequest: {0}>".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 "<HTTPResponse: {code} {msg} ({contenttype}, {size})>".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 = "<HTTPFlow"
|
||||
for a in ("request", "response", "error", "client_conn", "server_conn"):
|
||||
if getattr(self, a, False):
|
||||
s += "\r\n %s = {flow.%s}" % (a,a)
|
||||
s += ">"
|
||||
return s.format(flow=self)
|
||||
|
||||
def copy(self):
|
||||
f = super(HTTPFlow, self).copy()
|
||||
if self.request:
|
||||
|
@ -22,6 +22,13 @@ class ClientConnection(tcp.BaseHandler, stateobject.SimpleStateObject):
|
||||
self.timestamp_end = None
|
||||
self.timestamp_ssl_setup = None
|
||||
|
||||
def __repr__(self):
|
||||
return "<ClientConnection: {ssl}{host}:{port}>".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 "<ServerConnection: {ssl}{host}:{port}>".format(
|
||||
ssl=ssl,
|
||||
host=self.address.host,
|
||||
port=self.address.port
|
||||
)
|
||||
|
||||
_stateobject_attributes = dict(
|
||||
state=list,
|
||||
peername=tuple,
|
||||
|
Loading…
Reference in New Issue
Block a user