aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy
diff options
context:
space:
mode:
Diffstat (limited to 'libmproxy')
-rw-r--r--libmproxy/console/__init__.py2
-rw-r--r--libmproxy/console/common.py4
-rw-r--r--libmproxy/console/flowdetailview.py4
-rw-r--r--libmproxy/flow.py11
-rw-r--r--libmproxy/protocol/http.py5
-rw-r--r--libmproxy/protocol/primitives.py4
-rw-r--r--libmproxy/proxy.py8
7 files changed, 23 insertions, 15 deletions
diff --git a/libmproxy/console/__init__.py b/libmproxy/console/__init__.py
index a316602c..092990b1 100644
--- a/libmproxy/console/__init__.py
+++ b/libmproxy/console/__init__.py
@@ -1008,7 +1008,7 @@ class ConsoleMaster(flow.FlowMaster):
self.statusbar.refresh_flow(c)
def process_flow(self, f, r):
- if self.state.intercept and f.match(self.state.intercept) and not f.request.is_replay():
+ if self.state.intercept and f.match(self.state.intercept) and not f.request.is_replay:
f.intercept()
else:
r.reply()
diff --git a/libmproxy/console/common.py b/libmproxy/console/common.py
index a94f7ae4..715bed80 100644
--- a/libmproxy/console/common.py
+++ b/libmproxy/console/common.py
@@ -172,7 +172,7 @@ def format_flow(f, focus, extended=False, hostheader=False, padding=2):
intercepting = f.intercepting,
req_timestamp = f.request.timestamp_start,
- req_is_replay = f.request.is_replay(),
+ req_is_replay = f.request.is_replay,
req_method = f.request.method,
req_acked = f.request.reply.acked,
req_url = f.request.get_url(hostheader=hostheader),
@@ -194,7 +194,7 @@ def format_flow(f, focus, extended=False, hostheader=False, padding=2):
d.update(dict(
resp_code = f.response.code,
- resp_is_replay = f.response.is_replay(),
+ resp_is_replay = f.response.is_replay,
resp_acked = f.response.reply.acked,
resp_clen = contentdesc,
resp_rate = "{0}/s".format(rate),
diff --git a/libmproxy/console/flowdetailview.py b/libmproxy/console/flowdetailview.py
index a26e5308..8392537e 100644
--- a/libmproxy/console/flowdetailview.py
+++ b/libmproxy/console/flowdetailview.py
@@ -74,9 +74,9 @@ class FlowDetailsView(urwid.ListBox):
)
text.extend(common.format_keyvals(parts, key="key", val="text", indent=4))
- if self.flow.request.client_conn:
+ if self.flow.client_conn:
text.append(urwid.Text([("head", "Client Connection:")]))
- cc = self.flow.request.client_conn
+ cc = self.flow.client_conn
parts = [
["Address", "%s:%s"%tuple(cc.address)],
["Requests", "%s"%cc.requestcount],
diff --git a/libmproxy/flow.py b/libmproxy/flow.py
index b1971469..bf9171a7 100644
--- a/libmproxy/flow.py
+++ b/libmproxy/flow.py
@@ -174,7 +174,7 @@ class ClientPlaybackState:
if self.flows and not self.current:
n = self.flows.pop(0)
n.request.reply = controller.DummyReply()
- n.request.client_conn = None
+ n.client_conn = None
self.current = master.handle_request(n.request)
if not testing and not self.current.response:
master.replay_request(self.current) # pragma: no cover
@@ -249,9 +249,10 @@ class StickyCookieState:
"""
Returns a (domain, port, path) tuple.
"""
+ raise NotImplementedError
return (
m["domain"] or f.request.host,
- f.request.port,
+ f.server_conn.address.port,
m["path"] or "/"
)
@@ -297,6 +298,7 @@ class StickyAuthState:
self.hosts = {}
def handle_request(self, f):
+ raise NotImplementedError
if "authorization" in f.request.headers:
self.hosts[f.request.host] = f.request.headers["authorization"]
elif f.match(self.flt):
@@ -665,11 +667,10 @@ class FlowMaster(controller.Master):
return f
def handle_request(self, r):
- if False and r.is_live(): # FIXME
+ if r.flow.client_conn and r.flow.client_conn.wfile:
app = self.apps.get(r)
if app:
- # FIXME: for the tcp proxy, use flow.client_conn.wfile
- err = app.serve(r, r.wfile, **{"mitmproxy.master": self})
+ err = app.serve(r, r.flow.client_conn.wfile, **{"mitmproxy.master": self})
if err:
self.add_event("Error in wsgi app. %s"%err, "error")
r.reply(KILL)
diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py
index be60f374..636e1b07 100644
--- a/libmproxy/protocol/http.py
+++ b/libmproxy/protocol/http.py
@@ -56,7 +56,7 @@ class decoded(object):
class HTTPMessage(stateobject.SimpleStateObject):
def __init__(self):
- self.flow = None # Will usually set by backref mixin
+ self.flow = None # will usually be set by the flow backref mixin
"""@type: HTTPFlow"""
def get_decoded_content(self):
@@ -197,7 +197,7 @@ class HTTPRequest(HTTPMessage):
timestamp_end: Timestamp indicating when request transmission ended
"""
def __init__(self, form_in, method, scheme, host, port, path, httpversion, headers, content,
- timestamp_start, timestamp_end, form_out=None):
+ timestamp_start=None, timestamp_end=None, form_out=None):
assert isinstance(headers, ODictCaseless) or not headers
HTTPMessage.__init__(self)
@@ -758,7 +758,6 @@ class HTTPFlow(Flow):
"""
Continue with the flow - called after an intercept().
"""
- assert self.intercepting
if self.request:
if not self.request.reply.acked:
self.request.reply()
diff --git a/libmproxy/protocol/primitives.py b/libmproxy/protocol/primitives.py
index f77e097b..f3fdd245 100644
--- a/libmproxy/protocol/primitives.py
+++ b/libmproxy/protocol/primitives.py
@@ -41,6 +41,7 @@ class Error(stateobject.SimpleStateObject):
@type msg: str
@type timestamp: float
"""
+ self.flow = None # will usually be set by the flow backref mixin
self.msg = msg
self.timestamp = timestamp or utils.timestamp()
@@ -88,6 +89,9 @@ class Flow(stateobject.SimpleStateObject, _BackreferenceMixin):
f._load_state(state)
return f
+ def __eq__(self, other):
+ return self is other
+
def copy(self):
f = copy.copy(self)
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py
index feff2259..53e3f575 100644
--- a/libmproxy/proxy.py
+++ b/libmproxy/proxy.py
@@ -55,6 +55,10 @@ class ClientConnection(tcp.BaseHandler, stateobject.SimpleStateObject):
if client_connection: # Eventually, this object is restored from state. We don't have a connection then.
tcp.BaseHandler.__init__(self, client_connection, address, server)
else:
+ self.connection = None
+ self.server = None
+ self.wfile = None
+ self.rfile = None
self.address = None
self.clientcert = None
@@ -86,7 +90,7 @@ class ClientConnection(tcp.BaseHandler, stateobject.SimpleStateObject):
@classmethod
def _from_state(cls, state):
- f = cls(None, None, None)
+ f = cls(None, tuple(), None)
f._load_state(state)
return f
@@ -141,7 +145,7 @@ class ServerConnection(tcp.TCPClient, stateobject.SimpleStateObject):
@classmethod
def _from_state(cls, state):
- f = cls(None)
+ f = cls(tuple())
f._load_state(state)
return f