Added test test_content_length_no_content_disposition from #10771

This commit is contained in:
Aron Podrigal 2020-07-13 00:52:36 -05:00
parent 1dd58c9333
commit 8d1a64b7ea
2 changed files with 13 additions and 0 deletions

View File

@ -681,6 +681,7 @@ class FieldStorage:
self.file = self.make_file()
else:
self.file = self.io_object()
self.__file = self.file
todo = self.length
if todo >= 0:
while todo > 0:

View File

@ -366,6 +366,18 @@ Larry
self.assertEqual(fs.list[0].name, 'submit-name')
self.assertEqual(fs.list[0].value, 'Larry')
def test_content_length_no_content_disposition(self):
body = b'{"test":123}'
env = {
'CONTENT_LENGTH': len(body),
'REQUEST_METHOD': 'POST',
'CONTENT_TYPE': 'application/json',
'wsgi.input': BytesIO(body),
}
form = cgi.FieldStorage(fp=env['wsgi.input'], environ=env)
self.assertEqual(form.file.read(), body.decode(form.encoding))
def test_field_storage_multipart_no_content_length(self):
fp = BytesIO(b"""--MyBoundary
Content-Disposition: form-data; name="my-arg"; filename="foo"