summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_cgi.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-09-11 12:22:38 (GMT)
committerGitHub <noreply@github.com>2019-09-11 12:22:38 (GMT)
commit99f0e81f43f64b83e18e8cb2a0b66c53a81a74ab (patch)
treecbd2af3a8c43d816e08d4a73db35e2e64e763b15 /Lib/test/test_cgi.py
parent0553369b9827bb5497bb7a65f64dd259781ae792 (diff)
downloadcpython-99f0e81f43f64b83e18e8cb2a0b66c53a81a74ab.zip
cpython-99f0e81f43f64b83e18e8cb2a0b66c53a81a74ab.tar.gz
cpython-99f0e81f43f64b83e18e8cb2a0b66c53a81a74ab.tar.bz2
bpo-20504 : in cgi.py, fix bug when a multipart/form-data request has… (GH-10638)
* bpo-20504 : in cgi.py, fix bug when a multipart/form-data request has no content-length header * Add Misc/NEWS.d/next file. * Add rst formatting for NEWS.d/next file * Reaplce assert by self.assertEqual (cherry picked from commit 2d7cacacc310b65b43e7e2de89e7722291dea6a4) Co-authored-by: Pierre Quentel <pierre.quentel@gmail.com>
Diffstat (limited to 'Lib/test/test_cgi.py')
-rw-r--r--Lib/test/test_cgi.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py
index f4e00c7..b46be67 100644
--- a/Lib/test/test_cgi.py
+++ b/Lib/test/test_cgi.py
@@ -363,6 +363,23 @@ Larry
self.assertEqual(fs.list[0].name, 'submit-name')
self.assertEqual(fs.list[0].value, 'Larry')
+ def test_field_storage_multipart_no_content_length(self):
+ fp = BytesIO(b"""--MyBoundary
+Content-Disposition: form-data; name="my-arg"; filename="foo"
+
+Test
+
+--MyBoundary--
+""")
+ env = {
+ "REQUEST_METHOD": "POST",
+ "CONTENT_TYPE": "multipart/form-data; boundary=MyBoundary",
+ "wsgi.input": fp,
+ }
+ fields = cgi.FieldStorage(fp, environ=env)
+
+ self.assertEqual(len(fields["my-arg"].file.read()), 5)
+
def test_fieldstorage_as_context_manager(self):
fp = BytesIO(b'x' * 10)
env = {'REQUEST_METHOD': 'PUT'}