aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/proxy.py
diff options
context:
space:
mode:
authorStephen Altamirano <stephen@evilrobotstuff.com>2011-07-26 22:47:08 -0700
committerStephen Altamirano <stephen@evilrobotstuff.com>2011-07-26 22:47:08 -0700
commit78049abac123332123990994b50a70bc789b7514 (patch)
tree51db18286a42ebe75392eecc3c71da6d69ccf67e /libmproxy/proxy.py
parente6288e2d0751502eee1a44723a36230c12b821f3 (diff)
downloadmitmproxy-78049abac123332123990994b50a70bc789b7514.tar.gz
mitmproxy-78049abac123332123990994b50a70bc789b7514.tar.bz2
mitmproxy-78049abac123332123990994b50a70bc789b7514.zip
Changes replace logic to function in both Python 2.6.x and 2.7.x
Tests now only assume Python 2.6.x rather than requiring 2.7.x. This does not preclude the use of flags as a kwarg in replace
Diffstat (limited to 'libmproxy/proxy.py')
-rw-r--r--libmproxy/proxy.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py
index 8d2888a4..e765d8b6 100644
--- a/libmproxy/proxy.py
+++ b/libmproxy/proxy.py
@@ -280,16 +280,16 @@ class Request(controller.Msg):
else:
return self.FMT_PROXY % (self.method, self.scheme, self.host, self.port, self.path, str(headers), content)
- def replace(self, pattern, repl, count=0, flags=0):
+ def replace(self, pattern, repl, *args, **kwargs):
"""
Replaces a regular expression pattern with repl in both the headers
and the body of the request. Returns the number of replacements
- made.
+ made.
"""
- self.content, c = re.subn(pattern, repl, self.content, count, flags)
- self.path, pc = re.subn(pattern, repl, self.path, count, flags)
+ self.content, c = re.subn(pattern, repl, self.content, *args, **kwargs)
+ self.path, pc = re.subn(pattern, repl, self.path, *args, **kwargs)
c += pc
- c += self.headers.replace(pattern, repl, count, flags)
+ c += self.headers.replace(pattern, repl, *args, **kwargs)
return c
@@ -418,14 +418,14 @@ class Response(controller.Msg):
data = (proto, str(headers), content)
return self.FMT%data
- def replace(self, pattern, repl, count=0, flags=0):
+ def replace(self, pattern, repl, *args, **kwargs):
"""
Replaces a regular expression pattern with repl in both the headers
and the body of the response. Returns the number of replacements
- made.
+ made.
"""
- self.content, c = re.subn(pattern, repl, self.content, count, flags)
- c += self.headers.replace(pattern, repl, count, flags)
+ self.content, c = re.subn(pattern, repl, self.content, *args, **kwargs)
+ c += self.headers.replace(pattern, repl, *args, **kwargs)
return c
@@ -497,13 +497,13 @@ class Error(controller.Msg):
def __eq__(self, other):
return self.get_state() == other.get_state()
- def replace(self, pattern, repl, count=0, flags=0):
+ def replace(self, pattern, repl, *args, **kwargs):
"""
Replaces a regular expression pattern with repl in both the headers
and the body of the request. Returns the number of replacements
- made.
+ made.
"""
- self.msg, c = re.subn(pattern, repl, self.msg, count, flags)
+ self.msg, c = re.subn(pattern, repl, self.msg, *args, **kwargs)
return c