From 2a5b81a6eafda5b9d78ad282f351c289f0847c45 Mon Sep 17 00:00:00 2001 From: Tianhua Ran Date: Sun, 11 Mar 2018 13:38:32 +0800 Subject: [PATCH] fix: cannot get content length during download connections should get content length from Content-Range if there is no Content-Length in the response during download connections close #967 --- .../com/liulishuo/filedownloader/util/FileDownloadUtils.java | 1 + 1 file changed, 1 insertion(+) diff --git a/library/src/main/java/com/liulishuo/filedownloader/util/FileDownloadUtils.java b/library/src/main/java/com/liulishuo/filedownloader/util/FileDownloadUtils.java index 9cc88193..97703478 100644 --- a/library/src/main/java/com/liulishuo/filedownloader/util/FileDownloadUtils.java +++ b/library/src/main/java/com/liulishuo/filedownloader/util/FileDownloadUtils.java @@ -578,6 +578,7 @@ public static long findInstanceLengthFromContentRange(FileDownloadConnection con public static long findContentLength(final int id, FileDownloadConnection connection) { long contentLength = FileDownloadUtils .convertContentLengthString(connection.getResponseHeaderField("Content-Length")); + if (contentLength < 0) contentLength = findInstanceLengthFromContentRange(connection); final String transferEncoding = connection.getResponseHeaderField("Transfer-Encoding"); if (contentLength < 0) {