简体   繁体   English

使用Apache HTTP组件监视下载进度

[英]Monitor download progress with apache http components

I have some big files to download with Apache's Http Components and I want to be able to display some progress info to users in the admin console of my web app. 我有一些大文件可以通过Apache的Http组件下载,我希望能够在Web应用程序的管理控制台中向用户显示一些进度信息。 What is the right way to monitor a download in progress using this library? 使用此库监视正在进行的下载的正确方法是什么? I will create a singleton to manage the ongoing downloads, what I need is a way to inspect the open connections and find out where they are at any given time. 我将创建一个单例文件来管理正在进行的下载,我需要的是一种检查打开的连接并找出它们在任何给定时间的位置的方法。

  1. Obtain the Content-Length response header first 首先获取Content-Length响应头
  2. Get the result as stream and process it byte-by-byte (in batches) 将结果作为流获取并逐字节处理(分批)
  3. Count the bytes processed and show the user the percentage of processed bytes from the total number of bytes (obtained on the 1st step) 计算已处理的字节数,并向用户显示已处理的字节占总字节数的百分比(在第一步中获得)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM