]> granicus.if.org Git - python/commitdiff
Fix bug 427345 [related to IE's additional input on POST request].
authorSteve Holden <steve@holdenweb.com>
Wed, 8 Jan 2003 18:53:18 +0000 (18:53 +0000)
committerSteve Holden <steve@holdenweb.com>
Wed, 8 Jan 2003 18:53:18 +0000 (18:53 +0000)
Lib/CGIHTTPServer.py

index b3f922bbd35d641aa21584c3f55a970f04c0e335..f14ebba7a39117127c79a2c1964734eae62c7719 100644 (file)
@@ -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: