From: Steve Holden Date: Wed, 8 Jan 2003 21:17:35 +0000 (+0000) Subject: Retrospectively fix code to handle IE's additional characters on certain X-Git-Tag: v2.2.3c1~184 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d1bd8299fa8cc1bef9e4a45a41e1e4c247dfcb0c;p=thirdparty%2FPython%2Fcpython.git Retrospectively fix code to handle IE's additional characters on certain web transactions more gracefully (through a fairly ugly hack). See bugs 430610 and 427345. --- diff --git a/Lib/CGIHTTPServer.py b/Lib/CGIHTTPServer.py index 2106a5397260..970572be6d22 100644 --- a/Lib/CGIHTTPServer.py +++ b/Lib/CGIHTTPServer.py @@ -26,6 +26,7 @@ import sys import urllib import BaseHTTPServer import SimpleHTTPServer +import select class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): @@ -199,6 +200,9 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): if pid != 0: # Parent pid, sts = os.waitpid(pid, 0) + # throw away additional data [see bug #427345] + while select.select([self.rfile], [], [], 0)[0]: + waste = self.rfile.read(1) if sts: self.log_error("CGI script exit status %#x", sts) return @@ -244,6 +248,9 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): if self.command.lower() == "post" and nbytes > 0: data = self.rfile.read(nbytes) fi.write(data) + # throw away additional data [see bug #427345] + while select.select([self.rfile._sock], [], [], 0)[0]: + waste = self.rfile._sock.recv(1) fi.close() shutil.copyfileobj(fo, self.wfile) if self.have_popen3: