Fix test_xmlrpc and make the CGI handler work with no CONTENT_LENGTH.

This commit is contained in:
Georg Brandl 2009-04-01 15:23:43 +00:00
parent c53306c217
commit 61fce3877c
2 changed files with 6 additions and 2 deletions

View 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)

View 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()