Transfer large files using HTTP/POST

ぐ巨炮叔叔 提交于 2019-12-11 04:35:30

问题


How can I upload (very) large file with HTTP protocol in C (or C++)?

I know it's not the right way to upload huge files, but that's not the point.

I've already seen sources about POST transfers of files in C++ but I noticed that, each time, the WHOLE binary file was included inside the POST sequence (between "--boundary").

So, before going deeper and deeper into Webkit/Gecko source code, does somebody know how do they do?


回答1:


You may use "Content-Range" header in HTTP POST request, to upload a slice of a huge file.

POST http://[server_ip]:80/upload?fn=xx.dat HTTP/1.1
Content-Range: bytes=0-4095
Content-Type: application/octet-stream
Content-Length: 4096

......



回答2:


You can use chunking method to send the data in chunks. This will allow you to send/receive data on a larger scale. Refer to RFC 2616 on how chunking really works.



来源:https://stackoverflow.com/questions/8927219/transfer-large-files-using-http-post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!