当响应标头不包含内容长度时,如何估计下载时间?

发布于 2024-10-04 01:20:36 字数 38 浏览 0 评论 0原文

当要下载的文件缺少内容长度信息时,如何估计下载进度/时间?谢谢

how do i estimate download progress/time when the file to be downloaded lacks the content-length information? Thanks

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

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

发布评论

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

评论(1

神爱温柔 2024-10-11 01:20:36

您发现自己处于一种相当不可能的情况,服务器不会向您发送内容长度,但接受字节范围请求(并且您确实需要知道需要多长时间),您可以使用 Python 使用 HTTP 查找远程文件 并进行二进制搜索以获得有关文件大小的一些概念。询问超出文件大小的范围,您将收到:

HTTPError: HTTP Error 416: Requested Range Not Satisfiable

You you find yourself in the rather improbable situation that the server won't send you content lengths but accepts byte range requests (and you really really need to know how long it'll take), you can use the code in Python seek on remote file using HTTP and do a binary search to get some notion about the file size. Ask for a range beyond the file size and you'll receive:

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