From 8a9f20b78cf1ae51d4c10cd892500c252aef2ca3 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Wed, 16 Feb 2011 22:37:04 +1300 Subject: [PATCH] Don't leave dangling browser connections for pipelined requests. --- libmproxy/dump.py | 4 ++++ libmproxy/flow.py | 3 ++- libmproxy/proxy.py | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libmproxy/dump.py b/libmproxy/dump.py index 7eff4992e..039fb9a74 100644 --- a/libmproxy/dump.py +++ b/libmproxy/dump.py @@ -20,6 +20,8 @@ class DumpMaster(flow.FlowMaster): def handle_response(self, msg): f = flow.FlowMaster.handle_response(self, msg) + if not f: + return if 0 < self.verbosity < 3: print >> self.outfile, ">>", print >> self.outfile, msg.request.short() @@ -41,6 +43,8 @@ class DumpMaster(flow.FlowMaster): print >> self.outfile, "\t", i print >> self.outfile, "<<" msg.ack() + self.state.delete_flow(f) + print [i.get_state() for i in self.state.flow_list] # begin nocover diff --git a/libmproxy/flow.py b/libmproxy/flow.py index 5aba5f76a..63da0230a 100644 --- a/libmproxy/flow.py +++ b/libmproxy/flow.py @@ -183,7 +183,8 @@ class State: """ f = self.flow_map.get(req.client_conn) if not f: - return False + f = Flow(req.client_conn) + self.add_browserconnect(f) f.request = req return f diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index ff0d9a965..54ff2ec30 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -454,8 +454,8 @@ class ProxyHandler(SocketServer.StreamRequestHandler): def handle(self): cc = ClientConnection(self.client_address) + cc.send(self.mqueue) while not cc.close: - cc.send(self.mqueue) self.handle_request(cc) cc = cc.copy() self.finish() @@ -471,6 +471,7 @@ class ProxyHandler(SocketServer.StreamRequestHandler): if request is None: cc.close = True return + if request.is_response(): response = request request = False