FileDownloader icon indicating copy to clipboard operation
FileDownloader copied to clipboard

1.7.5在4G的情况下,progress回调大概率获取不到文件大小-->totalBytes=-1,wifi状态下没问题

Open 1370232877 opened this issue 7 years ago • 10 comments

如题

1370232877 avatar Sep 12 '18 09:09 1370232877

和我一样,totalBytes 值是 -1

Reginer avatar Sep 26 '18 05:09 Reginer

是不是用了gzip压缩了资源?可以通过添加Accept-Encoding为identity解决

royorange avatar Dec 14 '18 17:12 royorange

请提供一下日志吧!

rantianhua avatar Dec 15 '18 07:12 rantianhua

我也一样。。。

Punishing avatar Aug 23 '19 07:08 Punishing

这是我开了 download.trial-connection-head-method=true head方法获取文件大小返回的错误日志。

2019-08-23 16:02:00.272 2577-2916/com.shanling.mwzs.debug:filedownloader W/System: A resource failed to call response.body().close(). 2019-08-23 16:02:00.884 2577-3136/com.shanling.mwzs.debug:filedownloader W/FileDownloader.DownloadLaunchRunnable: get 416, precondition failed and just retry 2019-08-23 16:02:00.888 2577-3136/com.shanling.mwzs.debug:filedownloader W/FileDownloader.DownloadLaunchRunnable: there is precondition failed on this request[165588909] with old etag["c8835094857d51:0"]、new etag["c8835094857d51:0"]、response code is 416 2019-08-23 16:02:00.896 2577-3136/com.shanling.mwzs.debug:filedownloader W/FileDownloader.DownloadLaunchRunnable: the old etag["c8835094857d51:0"] is the same to the new etag["c8835094857d51:0"], but the response status code is 416 not Partial(206), so wo have to start this task from very beginning for task[165588909]! 2019-08-23 16:02:01.307 2577-3136/com.shanling.mwzs.debug:filedownloader W/FileDownloader.DownloadLaunchRunnable: get 416, precondition failed and need to retry with discarding range 2019-08-23 16:02:01.754 2577-3136/com.shanling.mwzs.debug:filedownloader W/FileDownloader.FileDownloadUtils: don't get instance length fromContent-Range header

由于此下载链接是合作方提供给我们APP的。。我们没办法控制他们服务器问题。

如果设置download.trial-connection-head-method=false是可以正常的。。但是其他下载链接又会碰到楼主 一样的问题。。请问是否能够动态设置download.trial-connection-head-method

Punishing avatar Aug 23 '19 08:08 Punishing

目前不支持动态设置。 @Punishing 你提供的日志来看,是他们服务器没有支持 head 方法,无法从 Content-Range 获取文件大小。我们这边商量一下是否有必要恢复 rang 为 0- 的方式去获取文件大小。

rantianhua avatar Aug 23 '19 11:08 rantianhua

请问 默认情况下是获取“content-length”数据长度吗?还是怎么获取 文件大小的

Punishing avatar Aug 26 '19 02:08 Punishing

获取文件长度默认是通过 GET 请求带上 [0-0] 的 Range ,然后在 Response Header 里面通过 Content-Range 拿。此时 Content-Length 是无效的。关于改用这种方式的原因,可以看 #933 。

rantianhua avatar Aug 26 '19 02:08 rantianhua

类似 这种链接https://downlhh.btgame99.com/index.php/index/down/gameid/7240/tgid/4803140 通过一个get请求获取的下载链接,如果我用这个链接调用FileDownloader.getImpl().create()你们有做特殊处理吗?

Punishing avatar Aug 30 '19 02:08 Punishing

比如发送 一个头部 range请求获取 文件大小的时候,针对我这种下载链接情况你们是怎么处理,我这边测试容易报http 返回码402错误?

Punishing avatar Aug 30 '19 02:08 Punishing