diff options
Diffstat (limited to 'libmproxy')
| -rw-r--r-- | libmproxy/filt.py | 27 | 
1 files changed, 26 insertions, 1 deletions
| diff --git a/libmproxy/filt.py b/libmproxy/filt.py index 4314f2d5..233cbb62 100644 --- a/libmproxy/filt.py +++ b/libmproxy/filt.py @@ -24,6 +24,12 @@          Patterns are matched against "name: value" strings. Field names are          all-lowercase. +        ~a          Asset content-type in response. Asset content types are: +                        text/javascript +                        application/x-javascript +                        text/css +                        image/* +                        application/x-shockwave-flash          ~h rex      Header line in either request or response          ~hq rex     Header in request          ~hs rex     Header in response @@ -95,6 +101,24 @@ def _check_content_type(expr, o):      return False +class FAsset(_Action): +    code = "a" +    help = "Match asset in response: CSS, Javascript, Flash, images." +    ASSET_TYPES = [ +        "text/javascript", +        "application/x-javascript", +        "text/css", +        "image/.*", +        "application/x-shockwave-flash" +    ] +    def __call__(self, f): +        if f.response: +            for i in self.ASSET_TYPES: +                if _check_content_type(i, f.response): +                    return True +        return False + +  class FContentType(_Rex):      code = "t"      help = "Content-type header" @@ -258,6 +282,7 @@ class FNot(_Token):  filt_unary = [      FReq,      FResp, +    FAsset,      FErr  ]  filt_rex = [ @@ -322,7 +347,7 @@ bnf = _make()  def parse(s):      try:          return bnf.parseString(s, parseAll=True)[0] -    except pp.ParseException: +    except pp.ParseException, v:          return None      except ValueError:          return None | 
