aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/net
diff options
context:
space:
mode:
authornaivekun <naivekun0817@gmail.com>2020-02-28 19:15:42 +0800
committernaivekun <naivekun0817@gmail.com>2020-03-02 01:29:47 +0800
commit3c1ced2b17bbd586332110d5242079bca5cbbe27 (patch)
treee3d9a3f863463f4f215f24ec00bc6f9162f3933a /mitmproxy/net
parent6d3b8c9716a274fdcc72c4dc9a841f2e8fa4d1e9 (diff)
downloadmitmproxy-3c1ced2b17bbd586332110d5242079bca5cbbe27.tar.gz
mitmproxy-3c1ced2b17bbd586332110d5242079bca5cbbe27.tar.bz2
mitmproxy-3c1ced2b17bbd586332110d5242079bca5cbbe27.zip
fix #3833
Diffstat (limited to 'mitmproxy/net')
-rw-r--r--mitmproxy/net/http/headers.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/mitmproxy/net/http/headers.py b/mitmproxy/net/http/headers.py
index 8a58cbbc..baed7e06 100644
--- a/mitmproxy/net/http/headers.py
+++ b/mitmproxy/net/http/headers.py
@@ -162,8 +162,12 @@ class Headers(multidict.MultiDict):
pattern = re.compile(pattern, flags)
replacements = 0
flag_count = count > 0
+ count_reached = False
fields = []
for name, value in self.fields:
+ if count_reached:
+ fields.append((name, value))
+ continue
line, n = pattern.subn(repl, name + b": " + value, count=count)
try:
name, value = line.split(b": ", 1)
@@ -173,10 +177,12 @@ class Headers(multidict.MultiDict):
pass
else:
replacements += n
+ fields.append((name, value))
if flag_count:
count -= n
if count == 0:
- break
+ count_reached = True
+ continue
fields.append((name, value))
self.fields = tuple(fields)
return replacements