mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-30 03:14:22 +00:00
fix #1850
This commit is contained in:
parent
b39380b00f
commit
e5b3c8bed3
@ -16,6 +16,7 @@ class Replace:
|
|||||||
rex: a regular expression, as bytes.
|
rex: a regular expression, as bytes.
|
||||||
s: the replacement string, as bytes
|
s: the replacement string, as bytes
|
||||||
"""
|
"""
|
||||||
|
if "replacements" in updated:
|
||||||
lst = []
|
lst = []
|
||||||
for fpatt, rex, s in options.replacements:
|
for fpatt, rex, s in options.replacements:
|
||||||
flt = flowfilter.parse(fpatt)
|
flt = flowfilter.parse(fpatt)
|
||||||
|
@ -8,6 +8,7 @@ class StickyAuth:
|
|||||||
self.hosts = {}
|
self.hosts = {}
|
||||||
|
|
||||||
def configure(self, options, updated):
|
def configure(self, options, updated):
|
||||||
|
if "stickyauth" in updated:
|
||||||
if options.stickyauth:
|
if options.stickyauth:
|
||||||
flt = flowfilter.parse(options.stickyauth)
|
flt = flowfilter.parse(options.stickyauth)
|
||||||
if not flt:
|
if not flt:
|
||||||
@ -15,8 +16,11 @@ class StickyAuth:
|
|||||||
"stickyauth: invalid filter expression: %s" % options.stickyauth
|
"stickyauth: invalid filter expression: %s" % options.stickyauth
|
||||||
)
|
)
|
||||||
self.flt = flt
|
self.flt = flt
|
||||||
|
else:
|
||||||
|
self.flt = None
|
||||||
|
|
||||||
def request(self, flow):
|
def request(self, flow):
|
||||||
|
if self.flt:
|
||||||
host = flow.request.host
|
host = flow.request.host
|
||||||
if "authorization" in flow.request.headers:
|
if "authorization" in flow.request.headers:
|
||||||
self.hosts[host] = flow.request.headers["authorization"]
|
self.hosts[host] = flow.request.headers["authorization"]
|
||||||
|
@ -34,6 +34,7 @@ class StickyCookie:
|
|||||||
self.flt = None
|
self.flt = None
|
||||||
|
|
||||||
def configure(self, options, updated):
|
def configure(self, options, updated):
|
||||||
|
if "stickycookie" in updated:
|
||||||
if options.stickycookie:
|
if options.stickycookie:
|
||||||
flt = flowfilter.parse(options.stickycookie)
|
flt = flowfilter.parse(options.stickycookie)
|
||||||
if not flt:
|
if not flt:
|
||||||
@ -41,6 +42,8 @@ class StickyCookie:
|
|||||||
"stickycookie: invalid filter expression: %s" % options.stickycookie
|
"stickycookie: invalid filter expression: %s" % options.stickycookie
|
||||||
)
|
)
|
||||||
self.flt = flt
|
self.flt = flt
|
||||||
|
else:
|
||||||
|
self.flt = None
|
||||||
|
|
||||||
def response(self, flow):
|
def response(self, flow):
|
||||||
if self.flt:
|
if self.flt:
|
||||||
|
@ -29,6 +29,8 @@ class StreamFile:
|
|||||||
raise exceptions.OptionsError(
|
raise exceptions.OptionsError(
|
||||||
"Invalid filter specification: %s" % options.filtstr
|
"Invalid filter specification: %s" % options.filtstr
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
self.filt = None
|
||||||
if "streamfile" in updated:
|
if "streamfile" in updated:
|
||||||
if self.stream:
|
if self.stream:
|
||||||
self.done()
|
self.done()
|
||||||
|
@ -15,7 +15,8 @@ def test_configure():
|
|||||||
|
|
||||||
def test_simple():
|
def test_simple():
|
||||||
r = stickyauth.StickyAuth()
|
r = stickyauth.StickyAuth()
|
||||||
with taddons.context():
|
with taddons.context() as tctx:
|
||||||
|
tctx.configure(r, stickyauth=".*")
|
||||||
f = tflow.tflow(resp=True)
|
f = tflow.tflow(resp=True)
|
||||||
f.request.headers["authorization"] = "foo"
|
f.request.headers["authorization"] = "foo"
|
||||||
r.request(f)
|
r.request(f)
|
||||||
|
Loading…
Reference in New Issue
Block a user