非常感谢西罗 · 桑蒂利的回答!我发现他对边界的选择是相当“不愉快”的,因为所有这些连字符: 事实上,正如@Fake Name 评论的那样,当你在请求中使用边界时,前面会多出两个连字符:
例如:
POST / HTTP/1.1
HOST: host.example.com
Cookie: some_cookies...
Connection: Keep-Alive
Content-Type: multipart/form-data; boundary=12345
--12345
Content-Disposition: form-data; name="sometext"
some text that you wrote in your html form ...
--12345
Content-Disposition: form-data; name="name_of_post_request" filename="filename.xyz"
content of filename.xyz that you upload in your form with input[type=file]
--12345
Content-Disposition: form-data; name="image" filename="picture_of_sunset.jpg"
content of picture_of_sunset.jpg ...
--12345--
我发现 在这个 w3.org 页面上可以在多部分/表单数据中封装多部分/混合头,只需在多部分/混合数据中选择另一个边界字符串,并使用该字符串封装数据。最后,您必须“关闭”FILO 中使用的所有边界,以关闭 POST 请求(比如:
POST / HTTP/1.1
...
Content-Type: multipart/form-data; boundary=12345
--12345
Content-Disposition: form-data; name="sometext"
some text sent via post...
--12345
Content-Disposition: form-data; name="files"
Content-Type: multipart/mixed; boundary=abcde
--abcde
Content-Disposition: file; file="picture.jpg"
content of jpg...
--abcde
Content-Disposition: file; file="test.py"
content of test.py file ....
--abcde--
--12345--