mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-01-30 23:09:44 +00:00
Merge pull request #21 from mehaase/master
Merge fixes from Mark E. Haase.
This commit is contained in:
commit
2a09cad420
@ -26,9 +26,9 @@ URL containing "google.com":
|
||||
|
||||
Requests whose body contains the string "test":
|
||||
|
||||
~r ~b test
|
||||
~q ~b test
|
||||
|
||||
Anything but requests with a text/html content type:
|
||||
|
||||
!(~r & ~t \"text/html\")
|
||||
!(~q & ~t \"text/html\")
|
||||
|
||||
|
@ -1499,8 +1499,8 @@ class ConsoleMaster(flow.FlowMaster):
|
||||
)
|
||||
examples = [
|
||||
("google\.com", "Url containing \"google.com"),
|
||||
("~r ~b test", "Requests where body contains \"test\""),
|
||||
("!(~r & ~t \"text/html\")", "Anything but requests with a text/html content type."),
|
||||
("~q ~b test", "Requests where body contains \"test\""),
|
||||
("!(~q & ~t \"text/html\")", "Anything but requests with a text/html content type."),
|
||||
]
|
||||
text.extend(format_keyvals(examples, key="key", val="text", indent=4))
|
||||
return urwid.ListBox([urwid.Text(text)])
|
||||
|
@ -34,6 +34,7 @@
|
||||
~bq rex Expression in the body of response
|
||||
~t rex Shortcut for content-type header.
|
||||
|
||||
~m rex Method
|
||||
~u rex URL
|
||||
~c CODE Response code.
|
||||
rex Equivalent to ~u rex
|
||||
@ -178,7 +179,18 @@ class FBodResponse(_Rex):
|
||||
elif o.content and re.search(self.expr, o.content):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
||||
class FMethod(_Rex):
|
||||
code = "m"
|
||||
help = "Method"
|
||||
def __call__(self, o):
|
||||
if o._is_response():
|
||||
return False
|
||||
elif o.method:
|
||||
return re.search(self.expr, o.method, re.IGNORECASE)
|
||||
return False
|
||||
|
||||
|
||||
class FUrl(_Rex):
|
||||
code = "u"
|
||||
@ -260,6 +272,7 @@ filt_rex = [
|
||||
FBodRequest,
|
||||
FBodResponse,
|
||||
FBod,
|
||||
FMethod,
|
||||
FUrl,
|
||||
FRequestContentType,
|
||||
FResponseContentType,
|
||||
|
@ -16,6 +16,7 @@ class uParsing(libpry.AutoTree):
|
||||
assert not filt.parse("~b")
|
||||
assert filt.parse("~q")
|
||||
assert filt.parse("~c 10")
|
||||
assert filt.parse("~m foobar")
|
||||
assert filt.parse("~u foobar")
|
||||
assert filt.parse("~q ~c 10")
|
||||
p = filt.parse("~q ~c 10")
|
||||
@ -171,6 +172,13 @@ class uMatching(libpry.AutoTree):
|
||||
assert not self.q("~bs response", q)
|
||||
assert self.q("~bs response", s)
|
||||
|
||||
def test_method(self):
|
||||
q = self.req()
|
||||
s = self.resp()
|
||||
assert self.q("~m get", q)
|
||||
assert not self.q("~m post", q)
|
||||
assert not self.q("~m get", s)
|
||||
|
||||
def test_url(self):
|
||||
q = self.req()
|
||||
s = self.resp()
|
||||
|
Loading…
Reference in New Issue
Block a user