From d6d1ff017078ceb1730da9d2138b3ebcdccb7972 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Thu, 9 Feb 2017 14:34:31 +0100 Subject: simplify state copy --- mitmproxy/connections.py | 7 ------- mitmproxy/flow.py | 16 ++-------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/mitmproxy/connections.py b/mitmproxy/connections.py index 9c4bca2f..a32889bd 100644 --- a/mitmproxy/connections.py +++ b/mitmproxy/connections.py @@ -1,6 +1,5 @@ import time -import copy import os from mitmproxy import stateobject @@ -82,9 +81,6 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject): tls_version=str, ) - def copy(self): - return copy.copy(self) - def send(self, message): if isinstance(message, list): message = b''.join(message) @@ -222,9 +218,6 @@ class ServerConnection(tcp.TCPClient, stateobject.StateObject): via=None )) - def copy(self): - return copy.copy(self) - def connect(self): self.timestamp_start = time.time() tcp.TCPClient.connect(self) diff --git a/mitmproxy/flow.py b/mitmproxy/flow.py index 7034cb4a..5ef957c9 100644 --- a/mitmproxy/flow.py +++ b/mitmproxy/flow.py @@ -1,5 +1,4 @@ import time -import copy import uuid from mitmproxy import controller # noqa @@ -7,7 +6,7 @@ from mitmproxy import stateobject from mitmproxy import connections from mitmproxy import version -import typing # noqa +import typing # noqa class Error(stateobject.StateObject): @@ -53,10 +52,6 @@ class Error(stateobject.StateObject): f.set_state(state) return f - def copy(self): - c = copy.copy(self) - return c - class Flow(stateobject.StateObject): @@ -116,16 +111,9 @@ class Flow(stateobject.StateObject): return f def copy(self): - f = copy.copy(self) - + f = super().copy() f.id = str(uuid.uuid4()) f.live = False - f.client_conn = self.client_conn.copy() - f.server_conn = self.server_conn.copy() - f.metadata = self.metadata.copy() - - if self.error: - f.error = self.error.copy() return f def modified(self): -- cgit v1.2.3