python cgi.FieldStorage在multipart / form-data类型的chunked传输上为空

时间:2014-08-07 09:50:40

标签: python apache cgi

如果指定了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
  • mime附件的Fieldstorage结果为空(但至少存在):FieldStorage(None, None, [MiniFieldStorage('bla', 'ddd'), FieldStorage(None, None, '')])

apache服务器不会记录任何错误。

知道我在这里缺少什么吗?

1 个答案:

答案 0 :(得分:0)