aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-02-10 15:04:20 +1300
committerAldo Cortesi <aldo@nullcube.com>2012-02-10 15:04:20 +1300
commitb14c29b25c4c5754edf568bcbb6bbf5b70b6c310 (patch)
tree21cf7e00219ee4a1a79c368a3abcd64caa947d0a /libmproxy
parent5326b7610a365d57ff06c0e72c739d2853b695f9 (diff)
downloadmitmproxy-b14c29b25c4c5754edf568bcbb6bbf5b70b6c310.tar.gz
mitmproxy-b14c29b25c4c5754edf568bcbb6bbf5b70b6c310.tar.bz2
mitmproxy-b14c29b25c4c5754edf568bcbb6bbf5b70b6c310.zip
Expand test coverage.
Diffstat (limited to 'libmproxy')
-rw-r--r--libmproxy/filt.py16
-rw-r--r--libmproxy/flow.py18
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))