Antoine Pitrou added the comment:

Note that forcing a content length on error responses also seems to make wget 
happy:


diff --git a/Lib/BaseHTTPServer.py b/Lib/BaseHTTPServer.py
--- a/Lib/BaseHTTPServer.py
+++ b/Lib/BaseHTTPServer.py
@@ -362,14 +362,19 @@
             message = short
         explain = long
         self.log_error("code %d, message %s", code, message)
-        # 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})
+        if self.command != 'HEAD' and code >= 200 and code not in (204, 304):
+            # 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})
+        else:
+            content = None
         self.send_response(code, message)
         self.send_header("Content-Type", self.error_content_type)
+        if content is not None:
+            self.send_header("Content-Length", str(len(content)))
         self.send_header('Connection', 'close')
         self.end_headers()
-        if self.command != 'HEAD' and code >= 200 and code not in (204, 304):
+        if content is not None:
             self.wfile.write(content)
 
     error_message_format = DEFAULT_ERROR_MESSAGE

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15991>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to