aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/http/request.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-07-01 14:10:48 -0700
committerMaximilian Hils <git@maximilianhils.com>2016-07-01 14:10:48 -0700
commit536c7acd13426d42dc863ae8b50e6c3a4cb2e858 (patch)
treee868530aef8353273a3107b57645fd5b02e717b0 /netlib/http/request.py
parente0ed7699ca1258414a99812720f168e14a6ca219 (diff)
downloadmitmproxy-536c7acd13426d42dc863ae8b50e6c3a4cb2e858.tar.gz
mitmproxy-536c7acd13426d42dc863ae8b50e6c3a4cb2e858.tar.bz2
mitmproxy-536c7acd13426d42dc863ae8b50e6c3a4cb2e858.zip
py3++
Diffstat (limited to 'netlib/http/request.py')
-rw-r--r--netlib/http/request.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/netlib/http/request.py b/netlib/http/request.py
index b64ccc51..ff057b79 100644
--- a/netlib/http/request.py
+++ b/netlib/http/request.py
@@ -65,10 +65,14 @@ class Request(message.Message):
Returns:
The number of replacements made.
"""
- # TODO: Proper distinction between text and bytes.
+ if isinstance(pattern, six.text_type):
+ pattern = strutils.escaped_str_to_bytes(pattern)
+ if isinstance(repl, six.text_type):
+ repl = strutils.escaped_str_to_bytes(repl)
+
c = super(Request, self).replace(pattern, repl, flags)
- self.path, pc = strutils.safe_subn(
- pattern, repl, self.path, flags=flags
+ self.path, pc = re.subn(
+ pattern, repl, self.data.path, flags=flags
)
c += pc
return c