简体   繁体   中英

python cgi.FieldStorage is empty on chunked transport of type multipart/form-data

Tested by apache-2.2.22 the python 3.3 cgi.FieldStorage() works perfectly for multipart/form-data if Content-Length is specified, however, the form data is empty if chunked transport is used. Please see the following two test cases.

Test_input_ok:

POST /cgi-bin/1.cgi?bla=ddd HTTP/1.1
Host: localhost
Content-Type: multipart/form-data; boundary=abcdefghdddddd
Content-Length: 162

--abcdefghdddddd
Content-Disposition: form-data; name="filename"; filename="freemind"
Content-Type: application/octet-stream

aaaaaaaaaa

--abcdefghdddddd--

FieldStorage result is OK: FieldStorage(None, None, [MiniFieldStorage('bla', 'ddd'), FieldStorage('filename', 'freemind', b'aaaaaaaaaa\\r\\n')])

Test_input_chunk_transport:

POST /cgi-bin/1.cgi?bla=ddd HTTP/1.1
Host: localhost
Transfer-Encoding: chunked
Content-Type: multipart/form-data; boundary=abcdefghdddddd

A6

--abcdefghdddddd
Content-Disposition: form-data; name="filename"; filename="freemind"
Content-Type: application/octet-stream

aaaaaaaaaa

--abcdefghdddddd--

0
  • Fieldstorage result for the mime attachment is empty (however, at least, present): FieldStorage(None, None, [MiniFieldStorage('bla', 'ddd'), FieldStorage(None, None, '')])

The apache server does not log any errors.

Any idea what I'm missing here?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM