From: Senthil Kumaran Date: Tue, 5 Mar 2013 10:28:18 +0000 (-0800) Subject: Reverting the changeset b87792757ee8 made for Issue #12921 X-Git-Tag: v3.4.0a1~1274 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=df1d3c5c4b5a235b4acd7700991363ad6fa8a3ca;p=python Reverting the changeset b87792757ee8 made for Issue #12921 --- df1d3c5c4b5a235b4acd7700991363ad6fa8a3ca diff --cc Lib/http/server.py index bb64ca6faf,c4ac703d2d..1873b13105 --- a/Lib/http/server.py +++ b/Lib/http/server.py @@@ -425,14 -425,12 +425,14 @@@ class BaseHTTPRequestHandler(socketserv # using _quote_html to prevent Cross Site Scripting attacks (see bug #1100201) content = (self.error_message_format % {'code': code, 'message': _quote_html(message), 'explain': explain}) + body = content.encode('UTF-8', 'replace') - self.send_response(code, shortmsg) + self.send_response(code, message) self.send_header("Content-Type", self.error_content_type) self.send_header('Connection', 'close') + self.send_header('Content-Length', int(len(body))) self.end_headers() if self.command != 'HEAD' and code >= 200 and code not in (204, 304): - self.wfile.write(content.encode('UTF-8', 'replace')) + self.wfile.write(body) def send_response(self, code, message=None): """Add the response header to the headers buffer and log the