This commit is contained in:
Maximilian Hils 2016-12-13 14:03:00 +01:00
parent b39380b00f
commit e5b3c8bed3
5 changed files with 47 additions and 36 deletions

View File

@ -16,6 +16,7 @@ class Replace:
rex: a regular expression, as bytes.
s: the replacement string, as bytes
"""
if "replacements" in updated:
lst = []
for fpatt, rex, s in options.replacements:
flt = flowfilter.parse(fpatt)

View File

@ -8,6 +8,7 @@ class StickyAuth:
self.hosts = {}
def configure(self, options, updated):
if "stickyauth" in updated:
if options.stickyauth:
flt = flowfilter.parse(options.stickyauth)
if not flt:
@ -15,8 +16,11 @@ class StickyAuth:
"stickyauth: invalid filter expression: %s" % options.stickyauth
)
self.flt = flt
else:
self.flt = None
def request(self, flow):
if self.flt:
host = flow.request.host
if "authorization" in flow.request.headers:
self.hosts[host] = flow.request.headers["authorization"]

View File

@ -34,6 +34,7 @@ class StickyCookie:
self.flt = None
def configure(self, options, updated):
if "stickycookie" in updated:
if options.stickycookie:
flt = flowfilter.parse(options.stickycookie)
if not flt:
@ -41,6 +42,8 @@ class StickyCookie:
"stickycookie: invalid filter expression: %s" % options.stickycookie
)
self.flt = flt
else:
self.flt = None
def response(self, flow):
if self.flt:

View File

@ -29,6 +29,8 @@ class StreamFile:
raise exceptions.OptionsError(
"Invalid filter specification: %s" % options.filtstr
)
else:
self.filt = None
if "streamfile" in updated:
if self.stream:
self.done()

View File

@ -15,7 +15,8 @@ def test_configure():
def test_simple():
r = stickyauth.StickyAuth()
with taddons.context():
with taddons.context() as tctx:
tctx.configure(r, stickyauth=".*")
f = tflow.tflow(resp=True)
f.request.headers["authorization"] = "foo"
r.request(f)