问题
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