diff options
Diffstat (limited to 'libmproxy')
| -rw-r--r-- | libmproxy/filt.py | 16 | ||||
| -rw-r--r-- | libmproxy/flow.py | 18 | 
2 files changed, 14 insertions, 20 deletions
diff --git a/libmproxy/filt.py b/libmproxy/filt.py index b5af44de..5fef33ba 100644 --- a/libmproxy/filt.py +++ b/libmproxy/filt.py @@ -1,16 +1,16 @@  # Copyright (C) 2010  Aldo Cortesi -#  +#  # This program is free software: you can redistribute it and/or modify  # it under the terms of the GNU General Public License as published by  # the Free Software Foundation, either version 3 of the License, or  # (at your option) any later version. -#  +#  # This program is distributed in the hope that it will be useful,  # but WITHOUT ANY WARRANTY; without even the implied warranty of  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  # GNU General Public License for more details. -#  +#  # You should have received a copy of the GNU General Public License  # along with this program.  If not, see <http://www.gnu.org/licenses/>. @@ -19,7 +19,7 @@          ~q          Request          ~s          Response -     +      Headers:          Patterns are matched against "name: value" strings. Field names are @@ -37,7 +37,7 @@          ~m rex      Method          ~u rex      URL          ~c CODE     Response code. -        rex         Equivalent to ~u rex  +        rex         Equivalent to ~u rex  """  import re, sys  import contrib.pyparsing as pp @@ -69,7 +69,7 @@ class FResp(_Action):      help = "Match response"      def __call__(self, conn):          return conn._is_response() -     +  class _Rex(_Action):      def __init__(self, expr): @@ -84,7 +84,7 @@ def _check_content_type(expr, o):      if val and re.search(expr, val[0]):          return True      return False -     +  class FContentType(_Rex):      code = "t" @@ -126,7 +126,7 @@ class FHead(_Rex):          if not val and o._is_response():              val = o.request.headers.match_re(self.expr)          return val -     +  class FHeadRequest(_Rex):      code = "hq" diff --git a/libmproxy/flow.py b/libmproxy/flow.py index beaa85ef..57a9310a 100644 --- a/libmproxy/flow.py +++ b/libmproxy/flow.py @@ -10,12 +10,6 @@ import controller, version  HDR_FORM_URLENCODED = "application/x-www-form-urlencoded" -class RunException(Exception): -    def __init__(self, msg, returncode, errout): -        Exception.__init__(self, msg) -        self.returncode = returncode -        self.errout = errout -  class ScriptContext:      def __init__(self, master): @@ -398,10 +392,10 @@ class Request(HTTPMsg):          if not 'host' in headers:              headers["host"] = [self._hostport()]          content = self.content -        if content is not None: -            headers["content-length"] = [str(len(content))] -        else: +        if content is None:              content = "" +        else: +            headers["content-length"] = [str(len(content))]          if self.close:              headers["connection"] = ["close"]          if not _proxy: @@ -555,10 +549,10 @@ class Response(HTTPMsg):              ['proxy-connection', 'connection', 'keep-alive', 'transfer-encoding']          )          content = self.content -        if content is not None: -            headers["content-length"] = [str(len(content))] -        else: +        if content is None:              content = "" +        else: +            headers["content-length"] = [str(len(content))]          if self.request.client_conn.close:              headers["connection"] = ["close"]          proto = "HTTP/1.1 %s %s"%(self.code, str(self.msg))  | 
