aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/http/request.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-04-03 08:17:30 -0700
committerMaximilian Hils <git@maximilianhils.com>2016-04-03 08:17:30 -0700
commit0259f479974f4f61e28bf1dac0d0f5229e468c36 (patch)
tree7bf64d328bf6dcbe12d4e8f4b6cba20125b3bf34 /netlib/http/request.py
parent84f650aabf739f40b3ff414c646257141babd6e1 (diff)
parent806aa0f41c7816b2859a6961939ed19499b73fe7 (diff)
downloadmitmproxy-0259f479974f4f61e28bf1dac0d0f5229e468c36.tar.gz
mitmproxy-0259f479974f4f61e28bf1dac0d0f5229e468c36.tar.bz2
mitmproxy-0259f479974f4f61e28bf1dac0d0f5229e468c36.zip
Merge branch 'better-replace'
Diffstat (limited to 'netlib/http/request.py')
-rw-r--r--netlib/http/request.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/netlib/http/request.py b/netlib/http/request.py
index db4901b7..692ba30f 100644
--- a/netlib/http/request.py
+++ b/netlib/http/request.py
@@ -54,6 +54,23 @@ class Request(Message):
self.method, hostport, path
)
+ def replace(self, pattern, repl, flags=0):
+ """
+ Replaces a regular expression pattern with repl in the headers, the
+ request path and the body of the request. Encoded content will be
+ decoded before replacement, and re-encoded afterwards.
+
+ Returns:
+ The number of replacements made.
+ """
+ # TODO: Proper distinction between text and bytes.
+ c = super(Request, self).replace(pattern, repl, flags)
+ self.path, pc = utils.safe_subn(
+ pattern, repl, self.path, flags=flags
+ )
+ c += pc
+ return c
+
@property
def first_line_format(self):
"""