]> granicus.if.org Git - python/commitdiff
Fix test_xmlrpc and make the CGI handler work with no CONTENT_LENGTH.
authorGeorg Brandl <georg@python.org>
Wed, 1 Apr 2009 15:23:43 +0000 (15:23 +0000)
committerGeorg Brandl <georg@python.org>
Wed, 1 Apr 2009 15:23:43 +0000 (15:23 +0000)
Lib/SimpleXMLRPCServer.py
Lib/test/test_xmlrpc.py

index 4c286884a3f1303fa9e2c86f0802d43731734644..b304e45c1128deba5032c9f97204ceea571bbfc0 100644 (file)
@@ -600,7 +600,7 @@ class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
             # POST data is normally available through stdin
             try:
                 length = int(os.environ.get('CONTENT_LENGTH', None))
-            except ValueError:
+            except (TypeError, ValueError):
                 length = -1
             if request_text is None:
                 request_text = sys.stdin.read(length)
index 05154cc5b594bd15d719e2f84f8481f165efa5a1..4f057c78a320910e029a7053c5e464521faeb4ba 100644 (file)
@@ -629,7 +629,11 @@ class CGIHandlerTestCase(unittest.TestCase):
         sys.stdin = open("xmldata.txt", "r")
         sys.stdout = open(test_support.TESTFN, "w")
 
-        self.cgi.handle_request()
+        os.environ['CONTENT_LENGTH'] = str(len(data))
+        try:
+            self.cgi.handle_request()
+        finally:
+            del os.environ['CONTENT_LENGTH']
 
         sys.stdin.close()
         sys.stdout.close()