diff --git a/mitmproxy/flowfilter.py b/mitmproxy/flowfilter.py index a63989579..6ca74b686 100644 --- a/mitmproxy/flowfilter.py +++ b/mitmproxy/flowfilter.py @@ -36,6 +36,7 @@ from __future__ import absolute_import, print_function, division import re import sys import functools +import six from mitmproxy.models.http import HTTPFlow from mitmproxy.models.tcp import TCPFlow @@ -501,16 +502,15 @@ def parse(s): return None -def match(self, flow, flt): +def match(flow, flt): """ - Match a flow against a compiled filter expression. + Matches a flow against a compiled filter expression. Returns True if matched, False if not. If flt is a string, it will be compiled as a filter expression. If the expression is invalid, ValueError is raised. """ if isinstance(flt, six.string_types): - flt = parse(flt) if not flt: raise ValueError("Invalid filter expression.") diff --git a/mitmproxy/models/flow.py b/mitmproxy/models/flow.py index f8c0b2102..6fce6e209 100644 --- a/mitmproxy/models/flow.py +++ b/mitmproxy/models/flow.py @@ -189,20 +189,9 @@ class Flow(stateobject.StateObject): self.reply.commit() master.handle_accept_intercept(self) - def match(self, flt): - """ - Matches a flow against a compiled filter expression. - Returns True if matched, False if not. + def match(self, f): + import warnings + warnings.warn(".match() is deprecated, please use flowfilter.match(some_flow, some_filter) instead.", DeprecationWarning) - If flt is a string, it will be compiled as a filter expression. - If the expression is invalid, ValueError is raised. - """ - if isinstance(flt, six.string_types): - from ..flowfilter import parse - - flt = parse(flt) - if not flt: - raise ValueError("Invalid filter expression.") - if flt: - return flt(self) - return True + from mitmproxy import flowfilter + return flowfilter.match(self, f)