mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Fix test_xmlrpc and make the CGI handler work with no CONTENT_LENGTH.
This commit is contained in:
parent
c53306c217
commit
61fce3877c
2 changed files with 6 additions and 2 deletions
|
@ -600,7 +600,7 @@ class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
|
||||||
# POST data is normally available through stdin
|
# POST data is normally available through stdin
|
||||||
try:
|
try:
|
||||||
length = int(os.environ.get('CONTENT_LENGTH', None))
|
length = int(os.environ.get('CONTENT_LENGTH', None))
|
||||||
except ValueError:
|
except (TypeError, ValueError):
|
||||||
length = -1
|
length = -1
|
||||||
if request_text is None:
|
if request_text is None:
|
||||||
request_text = sys.stdin.read(length)
|
request_text = sys.stdin.read(length)
|
||||||
|
|
|
@ -629,7 +629,11 @@ class CGIHandlerTestCase(unittest.TestCase):
|
||||||
sys.stdin = open("xmldata.txt", "r")
|
sys.stdin = open("xmldata.txt", "r")
|
||||||
sys.stdout = open(test_support.TESTFN, "w")
|
sys.stdout = open(test_support.TESTFN, "w")
|
||||||
|
|
||||||
|
os.environ['CONTENT_LENGTH'] = str(len(data))
|
||||||
|
try:
|
||||||
self.cgi.handle_request()
|
self.cgi.handle_request()
|
||||||
|
finally:
|
||||||
|
del os.environ['CONTENT_LENGTH']
|
||||||
|
|
||||||
sys.stdin.close()
|
sys.stdin.close()
|
||||||
sys.stdout.close()
|
sys.stdout.close()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue