minor bug fix header replace

This commit is contained in:
arjun23496 2016-08-31 16:11:59 +05:30
parent d2cfa5ca41
commit dd2e0d1df3

View File

@ -172,6 +172,7 @@ class Headers(multidict.MultiDict):
repl = strutils.escaped_str_to_bytes(repl)
pattern = re.compile(pattern, flags)
replacements = 0
flag_count = count > 0
fields = []
for name, value in self.fields:
@ -183,10 +184,13 @@ class Headers(multidict.MultiDict):
# There's not much we can do about this, so we just keep the header as-is.
pass
else:
count -= n
replacements += n
if count == 0:
break;
if flag_count:
count -= n
if count == 0:
break;
fields.append((name, value))
self.fields = tuple(fields)
return replacements