This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients catalin.iacob, neologix, pitrou, theamk, thomaslee
Date 2012-09-24.00:13:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1348445622.84.0.483449825934.issue15991@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2012-09-24 00:13:46pitrousetrecipients: + pitrou, thomaslee, neologix, catalin.iacob, theamk
2012-09-24 00:13:42pitrousetmessageid: <1348445622.84.0.483449825934.issue15991@psf.upfronthosting.co.za>
2012-09-24 00:13:42pitroulinkissue15991 messages
2012-09-24 00:13:39pitroucreate