aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/flow.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2011-02-03 14:51:32 +1300
committerAldo Cortesi <aldo@nullcube.com>2011-02-03 14:51:32 +1300
commit2cb7429d38243d95664791d3edd7c4894efd6ee9 (patch)
treee0f0e43515cb1b15c5a5de403814c54f33c62b09 /libmproxy/flow.py
parent7924f0797114dffb6224febc0a533dba8c500c40 (diff)
downloadmitmproxy-2cb7429d38243d95664791d3edd7c4894efd6ee9.tar.gz
mitmproxy-2cb7429d38243d95664791d3edd7c4894efd6ee9.tar.bz2
mitmproxy-2cb7429d38243d95664791d3edd7c4894efd6ee9.zip
Change "connection" to the less confusing "client_conn" throughout.
Diffstat (limited to 'libmproxy/flow.py')
-rw-r--r--libmproxy/flow.py54
1 files changed, 27 insertions, 27 deletions
diff --git a/libmproxy/flow.py b/libmproxy/flow.py
index 9ebe1d69..22ed79e4 100644
--- a/libmproxy/flow.py
+++ b/libmproxy/flow.py
@@ -29,14 +29,14 @@ class ReplayThread(threading.Thread):
response = server.read_response()
response.send(self.masterq)
except proxy.ProxyError, v:
- err = proxy.Error(self.flow.connection, v.msg)
+ err = proxy.Error(self.flow.client_conn, v.msg)
err.send(self.masterq)
# end nocover
class Flow:
- def __init__(self, connection):
- self.connection = connection
+ def __init__(self, client_conn):
+ self.client_conn = client_conn
self.request, self.response, self.error = None, None, None
self.intercepting = False
self._backup = None
@@ -131,7 +131,7 @@ class Flow:
def backup(self):
if not self._backup:
self._backup = [
- self.connection.copy() if self.connection else None,
+ self.client_conn.copy() if self.client_conn else None,
self.request.copy() if self.request else None,
self.response.copy() if self.response else None,
self.error.copy() if self.error else None,
@@ -140,7 +140,7 @@ class Flow:
def revert(self):
if self._backup:
restore = [i.copy() if i else None for i in self._backup]
- self.connection, self.request, self.response, self.error = restore
+ self.client_conn, self.request, self.response, self.error = restore
self._backup = None
def match(self, pattern):
@@ -152,7 +152,7 @@ class Flow:
return False
def is_replay(self):
- return isinstance(self.connection, ReplayConnection)
+ return isinstance(self.client_conn, ReplayConnection)
def kill(self):
if self.request and not self.request.acked:
@@ -188,13 +188,13 @@ class State:
Start a browser connection.
"""
self.flow_list.insert(0, f)
- self.flow_map[f.connection] = f
+ self.flow_map[f.client_conn] = f
def add_request(self, req):
"""
Add a request to the state. Returns the matching flow.
"""
- f = self.flow_map.get(req.connection)
+ f = self.flow_map.get(req.client_conn)
if not f:
return False
f.request = req
@@ -204,7 +204,7 @@ class State:
"""
Add a response to the state. Returns the matching flow.
"""
- f = self.flow_map.get(resp.request.connection)
+ f = self.flow_map.get(resp.request.client_conn)
if not f:
return False
f.response = resp
@@ -215,7 +215,7 @@ class State:
Add an error response to the state. Returns the matching flow, or
None if there isn't one.
"""
- f = self.flow_map.get(err.connection)
+ f = self.flow_map.get(err.client_conn)
if not f:
return None
f.error = err
@@ -245,26 +245,26 @@ class State:
else:
return tuple(self.flow_list[:])
- def get_connection(self, itm):
- if isinstance(itm, (proxy.BrowserConnection, ReplayConnection)):
+ def get_client_conn(self, itm):
+ if isinstance(itm, (proxy.ClientConnection, ReplayConnection)):
return itm
- elif hasattr(itm, "connection"):
- return itm.connection
+ elif hasattr(itm, "client_conn"):
+ return itm.client_conn
elif hasattr(itm, "request"):
- return itm.request.connection
+ return itm.request.client_conn
def lookup(self, itm):
"""
- Checks for matching connection, using a Flow, Replay Connection,
- BrowserConnection, Request, Response or Error object. Returns None
+ Checks for matching client_conn, using a Flow, Replay Connection,
+ ClientConnection, Request, Response or Error object. Returns None
if not found.
"""
- connection = self.get_connection(itm)
- return self.flow_map.get(connection)
+ client_conn = self.get_client_conn(itm)
+ return self.flow_map.get(client_conn)
def delete_flow(self, f):
if not f.intercepting:
- c = self.get_connection(f)
+ c = self.get_client_conn(f)
if c in self.flow_map:
del self.flow_map[c]
self.flow_list.remove(f)
@@ -285,17 +285,17 @@ class State:
def revert(self, f):
"""
- Replaces the matching connection object with a ReplayConnection object.
+ Replaces the matching client_conn object with a ReplayConnection object.
"""
- conn = self.get_connection(f)
+ conn = self.get_client_conn(f)
if conn in self.flow_map:
del self.flow_map[conn]
f.revert()
- self.flow_map[f.connection] = f
+ self.flow_map[f.client_conn] = f
def replay(self, f, masterq):
"""
- Replaces the matching connection object with a ReplayConnection object.
+ Replaces the matching client_conn object with a ReplayConnection object.
Returns None if successful, or error message if not.
"""
@@ -304,12 +304,12 @@ class State:
return "Can't replay while intercepting..."
if f.request:
f.backup()
- conn = self.get_connection(f)
+ conn = self.get_client_conn(f)
if conn in self.flow_map:
del self.flow_map[conn]
rp = ReplayConnection()
- f.connection = rp
- f.request.connection = rp
+ f.client_conn = rp
+ f.request.client_conn = rp
if f.request.content:
f.request.headers["content-length"] = [str(len(f.request.content))]
f.response = None