使用 Apache Httpclient 时,有没有办法获取下载状态?

发布于 2024-10-31 07:38:02 字数 31 浏览 2 评论 0原文

无论如何,要让他下载状态,比如它已经完成了多少?

Anyway to get he downloading status like how much it has finished?

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

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

发布评论

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

评论(1

睡美人的小仙女 2024-11-07 07:38:02

这取决于™:服务器可以(或不)在发送内容之前发送 Content-Length 标头。在这种情况下,是的,这是可能的:获取标头值,然后获取响应输出流并按固定大小的块从中读取,并在每次迭代时更新状态。
如果标题不存在,则不,您不知道要阅读的其余内容。

It depends™: the server can (or not) send a Content-Length header before it sends the content itseft. In this case, yes, it's possible: get the header value, then get the response output steam and read from it by chunks of fixed size, and update the status at each iteration.
If the header is not present, no, you have no clue about the remaining content to read.

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