使用 HTTP/POST 传输大文件

发布于 2024-12-28 00:08:34 字数 207 浏览 5 评论 0原文

如何使用 C(或 C++)中的 HTTP 协议上传(非常)大的文件?

我知道这不是上传大文件的正确方法,但这不是重点。

我已经看过有关 C++ 中文件 POST 传输的资料,但我注意到,每次,整个二进制文件都包含在 POST 序列内(在“--boundary”之间)。

那么,在深入研究 Webkit/Gecko 源代码之前,有人知道它们是怎么做的吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

感性 2025-01-04 00:08:35

您可以在 HTTP POST 请求中使用“Content-Range”标头来上传大文件的一部分。

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

......

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

......
无言温柔 2025-01-04 00:08:35

您可以使用分块方法以块的形式发送数据。这将允许您更大规模地发送/接收数据。请参阅 RFC 2616 了解分块的实际工作原理。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文