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.
This commit is contained in:
Aldo Cortesi 2011-02-21 10:11:50 +13:00
parent fd4dd8cb6b
commit c3e3897071
1 changed files with 1 additions and 1 deletions

View File

@ -338,7 +338,7 @@ class Response(controller.Msg):
content = "" content = ""
if self.request.client_conn.close: if self.request.client_conn.close:
headers["connection"] = ["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) data = (proto, str(headers), content)
return self.FMT%data return self.FMT%data