mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
Add test for body (~b)
This commit is contained in:
parent
88671c3aac
commit
124b87b851
@ -193,12 +193,22 @@ class FBod(_Rex):
|
|||||||
help = "Body"
|
help = "Body"
|
||||||
|
|
||||||
def __call__(self, f):
|
def __call__(self, f):
|
||||||
if f.request and f.request.content:
|
|
||||||
if self.re.search(f.request.get_decoded_content()):
|
# HTTPFlow
|
||||||
return True
|
if hasattr(f, 'request'):
|
||||||
if f.response and f.response.content:
|
if f.request and f.request.content:
|
||||||
if self.re.search(f.response.get_decoded_content()):
|
if self.re.search(f.request.get_decoded_content()):
|
||||||
return True
|
return True
|
||||||
|
if f.response and f.response.content:
|
||||||
|
if self.re.search(f.response.get_decoded_content()):
|
||||||
|
return True
|
||||||
|
|
||||||
|
# TCPFlow
|
||||||
|
elif hasattr(f, 'messages'):
|
||||||
|
for msg in f.messages:
|
||||||
|
if self.re.search(msg.content):
|
||||||
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@ -262,6 +262,13 @@ class TestMatchingTCPFlow:
|
|||||||
e = self.err()
|
e = self.err()
|
||||||
assert self.q("~e", e)
|
assert self.q("~e", e)
|
||||||
|
|
||||||
|
def test_body(self):
|
||||||
|
f = self.flow()
|
||||||
|
assert not self.q("~b nonexistent", f)
|
||||||
|
assert self.q("~b hello", f)
|
||||||
|
assert self.q("~b me", f)
|
||||||
|
|
||||||
|
|
||||||
@patch('traceback.extract_tb')
|
@patch('traceback.extract_tb')
|
||||||
def test_pyparsing_bug(extract_tb):
|
def test_pyparsing_bug(extract_tb):
|
||||||
"""https://github.com/mitmproxy/mitmproxy/issues/1087"""
|
"""https://github.com/mitmproxy/mitmproxy/issues/1087"""
|
||||||
|
Loading…
Reference in New Issue
Block a user