mirror of
https://github.com/zhigang1992/mitmproxy.git
synced 2026-05-07 10:22:11 +08:00
fix #341 - work on flows instead of request/response internally.
This commit is contained in:
@@ -9,24 +9,6 @@ from ..proxy.connection import ClientConnection, ServerConnection
|
||||
KILL = 0 # const for killed requests
|
||||
|
||||
|
||||
class BackreferenceMixin(object):
|
||||
"""
|
||||
If an attribute from the _backrefattr tuple is set,
|
||||
this mixin sets a reference back on the attribute object.
|
||||
Example:
|
||||
e = Error()
|
||||
f = Flow()
|
||||
f.error = e
|
||||
assert f is e.flow
|
||||
"""
|
||||
_backrefattr = tuple()
|
||||
|
||||
def __setattr__(self, key, value):
|
||||
super(BackreferenceMixin, self).__setattr__(key, value)
|
||||
if key in self._backrefattr and value is not None:
|
||||
setattr(value, self._backrefname, self)
|
||||
|
||||
|
||||
class Error(stateobject.SimpleStateObject):
|
||||
"""
|
||||
An Error.
|
||||
@@ -70,7 +52,7 @@ class Error(stateobject.SimpleStateObject):
|
||||
return c
|
||||
|
||||
|
||||
class Flow(stateobject.SimpleStateObject, BackreferenceMixin):
|
||||
class Flow(stateobject.SimpleStateObject):
|
||||
def __init__(self, conntype, client_conn, server_conn, live=None):
|
||||
self.conntype = conntype
|
||||
self.client_conn = client_conn
|
||||
@@ -84,9 +66,6 @@ class Flow(stateobject.SimpleStateObject, BackreferenceMixin):
|
||||
"""@type: Error"""
|
||||
self._backup = None
|
||||
|
||||
_backrefattr = ("error",)
|
||||
_backrefname = "flow"
|
||||
|
||||
_stateobject_attributes = dict(
|
||||
error=Error,
|
||||
client_conn=ClientConnection,
|
||||
|
||||
Reference in New Issue
Block a user