FileDownloader icon indicating copy to clipboard operation
FileDownloader copied to clipboard

1.7.7版本,下载出现412错误,设置忽略Etag,出现提示后端错误,但下载链接是亚马逊云,这个链接在其他下载工具是可以正常下载的

Open PeOS-China opened this issue 4 years ago • 1 comments

    FileDownloader
            .setupOnApplicationOnCreate(application)
            .connectionCreator(FileDownloadUrlConnection.Creator(FileDownloadUrlConnection.Configuration()
                    .connectTimeout(15000) // set connection timeout.
                    .readTimeout(15000) // set read timeout.
            ))
            .connectionCountAdapter { _, _, _, _ -> 1 }
            .commit()

以上设置 出现421错误: Connection failed with request[{If-Match=["9b09ab4bfa1125950b26ea93610dc487-26"], Range=[bytes=354903012-], User-Agent=[FileDownloader/1.7.7]}] response[{null=[HTTP/1.1 412 Precondition Failed], Connection=[keep-alive], Content-Type=[application/xml], Date=[Mon, 08 Feb 2021 03:24:03 GMT], Server=[AmazonS3], Transfer-Encoding=[chunked], Via=[1.1 34bd50b1d81b6dab6060e9282ae29c40.cloudfront.net (CloudFront)], X-Amz-Cf-Id=[0_oKujlpTXrW5ogwQBy5jFkxs-sIapcZ59_MqvGVU4NTCkQS19vPPA==], X-Amz-Cf-Pop=[HKG54-C1], X-Android-Received-Millis=[1612754643879], X-Android-Response-Source=[NETWORK 412], X-Android-Selected-Protocol=[http/1.1], X-Android-Sent-Millis=[1612754642996], X-Cache=[Error from cloudfront]}] http-state[412] on task[1763934570-4], which is changed after verify connection, so please try again

所以,修改了配置,忽略Etag: FileDownloader.setupOnApplicationOnCreate(application) .connectionCreator(object : FileDownloadUrlConnection .Creator(FileDownloadUrlConnection.Configuration() .connectTimeout(15_000) // set connection timeout. .readTimeout(15_000) // set read timeout. ) { override fun create(originUrl: String) : FileDownloadConnection { return NoEtagFileDownloadUrlConnection(originUrl) } }) .commit()

public class NoEtagFileDownloadUrlConnection extends FileDownloadUrlConnection {

public NoEtagFileDownloadUrlConnection(String originUrl, Configuration configuration) throws IOException {
    super(originUrl, configuration);
}

public NoEtagFileDownloadUrlConnection(URL url, Configuration configuration) throws IOException {
    super(url, configuration);
}

public NoEtagFileDownloadUrlConnection(String originUrl) throws IOException {
    super(originUrl);
}

@Override
public void addHeader(String name, String value) {
    if ("If-Match".equals(name)) {
        return;
    }
    super.addHeader(name, value);
}

}

但是,出现了其他异常: require range[354903012-) with contentLength(88725753), but the backend response contentLength is 88698155 on downloadId[1763934570]-connectionIndex[4], please ask your backend dev to fix such problem.

PeOS-China avatar Feb 08 '21 03:02 PeOS-China

请问这个问题处理了吗?

ChinaZeng avatar Oct 21 '21 09:10 ChinaZeng