summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-04-01 15:23:43 (GMT)
committerGeorg Brandl <georg@python.org>2009-04-01 15:23:43 (GMT)
commit61fce3877cd11508f43b4d4e71276b03c3ef2823 (patch)
treeccbc8caf671628f86bf0997dfd99543da5efabd3
parentc53306c21734e90a6bf2f6676eb9f0c9486548a4 (diff)
downloadcpython-61fce3877cd11508f43b4d4e71276b03c3ef2823.zip
cpython-61fce3877cd11508f43b4d4e71276b03c3ef2823.tar.gz
cpython-61fce3877cd11508f43b4d4e71276b03c3ef2823.tar.bz2
Fix test_xmlrpc and make the CGI handler work with no CONTENT_LENGTH.
-rw-r--r--Lib/SimpleXMLRPCServer.py2
-rw-r--r--Lib/test/test_xmlrpc.py6
2 files changed, 6 insertions, 2 deletions
diff --git a/Lib/SimpleXMLRPCServer.py b/Lib/SimpleXMLRPCServer.py
index 4c28688..b304e45 100644
--- a/Lib/SimpleXMLRPCServer.py
+++ b/Lib/SimpleXMLRPCServer.py
@@ -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)
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
index 05154cc..4f057c7 100644
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -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()