From c3e38970718aed37dd70e8aad0085957b62a09ac Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 21 Feb 2011 10:11:50 +1300 Subject: Fix a subtle Unicode problem in Response.assemble If msg is Unicode, the proto string is automatically promoted to Unicode. If the proto string is promoted to Unicode, then the FMT interpolation is also done in Unicode. If this happens, then binary data in content will cause an exception. --- libmproxy/proxy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index 5e698c5f..ffc9b264 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -338,7 +338,7 @@ class Response(controller.Msg): content = "" if self.request.client_conn.close: headers["connection"] = ["close"] - proto = "HTTP/1.1 %s %s"%(self.code, self.msg) + proto = "HTTP/1.1 %s %s"%(self.code, str(self.msg)) data = (proto, str(headers), content) return self.FMT%data -- cgit v1.2.3