diff options
author | Thomas Kriechbaumer <Kriechi@users.noreply.github.com> | 2016-08-31 13:49:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-31 13:49:03 +0200 |
commit | b4b2e5fd3431ea3c8b8f00b8f92e8c7fc6f309ae (patch) | |
tree | 6ce6930f0f2db77c7d90bb940b359f4ea5eded73 /netlib/http/message.py | |
parent | 6afbfc85266e783b1bad432ae1f6715bfb16a39f (diff) | |
parent | a8deed1f4ef5992b1c9c74ac69491bdb5f0e8490 (diff) | |
download | mitmproxy-b4b2e5fd3431ea3c8b8f00b8f92e8c7fc6f309ae.tar.gz mitmproxy-b4b2e5fd3431ea3c8b8f00b8f92e8c7fc6f309ae.tar.bz2 mitmproxy-b4b2e5fd3431ea3c8b8f00b8f92e8c7fc6f309ae.zip |
Merge pull request #1511 from arjun23496/count_in_replace
Fixes #1495 - Added count argument for replacing contents in body
Diffstat (limited to 'netlib/http/message.py')
-rw-r--r-- | netlib/http/message.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/netlib/http/message.py b/netlib/http/message.py index ce92bab1..0b64d4a6 100644 --- a/netlib/http/message.py +++ b/netlib/http/message.py @@ -260,7 +260,7 @@ class Message(basetypes.Serializable): if "content-encoding" not in self.headers: raise ValueError("Invalid content encoding {}".format(repr(e))) - def replace(self, pattern, repl, flags=0): + def replace(self, pattern, repl, flags=0, count=0): """ Replaces a regular expression pattern with repl in both the headers and the body of the message. Encoded body will be decoded @@ -276,9 +276,9 @@ class Message(basetypes.Serializable): replacements = 0 if self.content: self.content, replacements = re.subn( - pattern, repl, self.content, flags=flags + pattern, repl, self.content, flags=flags, count=count ) - replacements += self.headers.replace(pattern, repl, flags) + replacements += self.headers.replace(pattern, repl, flags=flags, count=count) return replacements # Legacy |