]> granicus.if.org Git - python/commitdiff
Fix Issue #12921: BaseHTTPServer's send_error should send the correct error
authorSenthil Kumaran <senthil@uthcode.com>
Tue, 5 Mar 2013 09:26:33 +0000 (01:26 -0800)
committerSenthil Kumaran <senthil@uthcode.com>
Tue, 5 Mar 2013 09:26:33 +0000 (01:26 -0800)
response message when  send_error includes a message in addition to error
status. Patch contributed by Karl.

1  2 
Lib/http/server.py
Misc/NEWS

index 1873b13105e1bc86d484c52558e85e568357e386,18a51fe5b772e5de4ab626c3fddf568d0606f6e5..bb64ca6fafd312f728e46474ed3481039dbfc079
@@@ -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})
-         self.send_response(code, message)
 +        body = content.encode('UTF-8', 'replace')
+         self.send_response(code, shortmsg)
          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
diff --cc Misc/NEWS
Simple merge