如果指定了Content-Length,则python 3.3 cgi.FieldStorage()通过apache-2.2.22测试python 3.3 cgi.FieldStorage()非常适用于multipart / form-data,但是,如果使用chunked transport,则表单数据为空。请参阅以下两个测试用例。
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结果没问题: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(None, None, [MiniFieldStorage('bla', 'ddd'), FieldStorage(None, None, '')])
apache服务器不会记录任何错误。
知道我在这里缺少什么吗?
答案 0 :(得分:0)