mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
Anchor management: list and remove anchors.
This commit is contained in:
parent
2d88d88f8c
commit
f03ce81070
@ -86,19 +86,35 @@ class PathodApp(tornado.web.Application):
|
||||
def __init__(self, application, request, **settings):
|
||||
Pathod.__init__(self, spec, application, request, **settings)
|
||||
FixedPathod.spec = spec
|
||||
FixedPathod.pattern = pattern
|
||||
l.insert(0, tornado.web.URLSpec(pattern, FixedPathod, self.appsettings))
|
||||
|
||||
def get_anchors(self, pattern, spec):
|
||||
def get_anchors(self):
|
||||
"""
|
||||
Anchors are added to the beginning of the handlers.
|
||||
"""
|
||||
pass
|
||||
l = self.handlers[0][1]
|
||||
a = []
|
||||
for i in l:
|
||||
if i.handler_class.__name__ == "FixedPathod":
|
||||
a.append(
|
||||
(
|
||||
i.handler_class.pattern,
|
||||
i.handler_class.spec
|
||||
)
|
||||
)
|
||||
return a
|
||||
|
||||
def remove_anchor(self, pattern, spec):
|
||||
"""
|
||||
Anchors are added to the beginning of the handlers.
|
||||
"""
|
||||
pass
|
||||
l = self.handlers[0][1]
|
||||
for i, h in enumerate(l):
|
||||
if h.handler_class.__name__ == "FixedPathod":
|
||||
if (h.handler_class.pattern, h.handler_class.spec) == (pattern, spec):
|
||||
del l[i]
|
||||
return
|
||||
|
||||
|
||||
# begin nocover
|
||||
|
10
notes
10
notes
@ -33,16 +33,10 @@ Examples:
|
||||
200:b1k:xr
|
||||
|
||||
|
||||
Sequences:
|
||||
|
||||
200 * 2 | !forever
|
||||
200 | 404 | 200,b:500g
|
||||
|
||||
|
||||
Anchors:
|
||||
|
||||
Passed on command-line?
|
||||
--anchor /foo/bar 200:!/foo
|
||||
Passed on command-line:
|
||||
-a "/foo/bar=200:!/foo"
|
||||
|
||||
|
||||
Built-in help
|
||||
|
@ -6,7 +6,13 @@ class uApplication(libpry.AutoTree):
|
||||
def test_anchors(self):
|
||||
a = app.PathodApp(staticdir=None)
|
||||
a.add_anchor("/foo", "200")
|
||||
assert a.handlers[0][1][0].handler_class.__name__ == "FixedPathod"
|
||||
assert a.get_anchors() == [("/foo", "200")]
|
||||
a.add_anchor("/bar", "400")
|
||||
assert a.get_anchors() == [("/bar", "400"), ("/foo", "200")]
|
||||
a.remove_anchor("/bar", "400")
|
||||
assert a.get_anchors() == [("/foo", "200")]
|
||||
a.remove_anchor("/oink", "400")
|
||||
assert a.get_anchors() == [("/foo", "200")]
|
||||
|
||||
|
||||
class uPages(libpry.AutoTree):
|
||||
|
Loading…
Reference in New Issue
Block a user