aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2016-10-27 08:26:48 +1300
committerGitHub <noreply@github.com>2016-10-27 08:26:48 +1300
commit72ac572226ec76a44cfe2b981ce6bd1bce6ab69a (patch)
tree306c1efea78a2b51c5f253692d212aee26297fef
parentd096b36068f744af2ac490b5cac931f3ddf30b5e (diff)
parentbb5811beec44df1c9e28e6060df12a82ac81864a (diff)
downloadmitmproxy-72ac572226ec76a44cfe2b981ce6bd1bce6ab69a.tar.gz
mitmproxy-72ac572226ec76a44cfe2b981ce6bd1bce6ab69a.tar.bz2
mitmproxy-72ac572226ec76a44cfe2b981ce6bd1bce6ab69a.zip
Merge pull request #1673 from mhils/issue-1620
fix #1620
-rw-r--r--mitmproxy/flow.py3
-rw-r--r--mitmproxy/tools/console/master.py9
-rw-r--r--mitmproxy/tools/web/master.py9
-rw-r--r--setup.cfg2
4 files changed, 14 insertions, 9 deletions
diff --git a/mitmproxy/flow.py b/mitmproxy/flow.py
index a23abf5f..ff7a2b4a 100644
--- a/mitmproxy/flow.py
+++ b/mitmproxy/flow.py
@@ -2,6 +2,7 @@ import time
import copy
import uuid
+from mitmproxy import controller # noqa
from mitmproxy import stateobject
from mitmproxy import connections
from mitmproxy import version
@@ -80,7 +81,7 @@ class Flow(stateobject.StateObject):
self.error = None # type: Optional[Error]
self.intercepted = False # type: bool
self._backup = None # type: Optional[Flow]
- self.reply = None
+ self.reply = None # type: Optional[controller.Reply]
self.marked = False # type: bool
_stateobject_attributes = dict(
diff --git a/mitmproxy/tools/console/master.py b/mitmproxy/tools/console/master.py
index c128e42b..1f48f350 100644
--- a/mitmproxy/tools/console/master.py
+++ b/mitmproxy/tools/console/master.py
@@ -659,11 +659,10 @@ class ConsoleMaster(master.Master):
)
def process_flow(self, f):
- should_intercept = any(
- [
- self.state.intercept and flowfilter.match(self.state.intercept, f) and not f.request.is_replay,
- f.intercepted,
- ]
+ should_intercept = (
+ self.state.intercept and flowfilter.match(self.state.intercept, f)
+ and not f.request.is_replay
+ and f.reply.state == "handled"
)
if should_intercept:
f.intercept(self)
diff --git a/mitmproxy/tools/web/master.py b/mitmproxy/tools/web/master.py
index 75842422..e95daf44 100644
--- a/mitmproxy/tools/web/master.py
+++ b/mitmproxy/tools/web/master.py
@@ -9,6 +9,7 @@ from typing import Optional
from mitmproxy import addons
from mitmproxy import controller
from mitmproxy import exceptions
+from mitmproxy import flowfilter
from mitmproxy.addons import state
from mitmproxy import options
from mitmproxy import master
@@ -179,8 +180,12 @@ class WebMaster(master.Master):
self.shutdown()
def _process_flow(self, f):
- if self.state.intercept and self.state.intercept(
- f) and not f.request.is_replay:
+ should_intercept = (
+ self.state.intercept and flowfilter.match(self.state.intercept, f)
+ and not f.request.is_replay
+ and f.reply.state == "handled"
+ )
+ if should_intercept:
f.intercept(self)
return f
diff --git a/setup.cfg b/setup.cfg
index 87ef81ed..df31020c 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,7 +1,7 @@
[flake8]
max-line-length = 140
max-complexity = 25
-ignore = E251,C901
+ignore = E251,C901,W503
exclude = mitmproxy/contrib/*,test/mitmproxy/data/*
addons = file,open,basestring,xrange,unicode,long,cmp