From 2654cd87afcba318d2cb6ba716a6e2106f24ccb7 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 8 Feb 2016 01:06:18 +0100 Subject: fix #876 --- libmproxy/models/http.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'libmproxy/models') diff --git a/libmproxy/models/http.py b/libmproxy/models/http.py index 8a0b226d..60fcb92c 100644 --- a/libmproxy/models/http.py +++ b/libmproxy/models/http.py @@ -91,10 +91,12 @@ class MessageMixin(stateobject.StateObject): Returns the number of replacements made. """ - with decoded(self): - self.content, count = utils.safe_subn( - pattern, repl, self.content, *args, **kwargs - ) + count = 0 + if self.content: + with decoded(self): + self.content, count = utils.safe_subn( + pattern, repl, self.content, *args, **kwargs + ) fields = [] for name, value in self.headers.fields: name, c = utils.safe_subn(pattern, repl, name, *args, **kwargs) -- cgit v1.2.3