You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2014/02/11 00:22:24 UTC
[12/17] git commit: CB-5762 android: Fix lengthComputable set wrong
for gzip downloads
CB-5762 android: Fix lengthComputable set wrong for gzip downloads
Gzip + no Content-Length header should be lengthComputable=false
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/commit/3c1ff160
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/3c1ff160
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/3c1ff160
Branch: refs/heads/master
Commit: 3c1ff1606447c3d6dadc5a032bbe987ac570188a
Parents: 613ee82
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Jan 10 11:44:55 2014 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Jan 10 11:45:59 2014 -0500
----------------------------------------------------------------------
src/android/FileTransfer.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/3c1ff160/src/android/FileTransfer.java
----------------------------------------------------------------------
diff --git a/src/android/FileTransfer.java b/src/android/FileTransfer.java
index f3ab9a0..5d7cbc0 100644
--- a/src/android/FileTransfer.java
+++ b/src/android/FileTransfer.java
@@ -760,8 +760,10 @@ public class FileTransfer extends CordovaPlugin {
if (connection.getContentEncoding() == null || connection.getContentEncoding().equalsIgnoreCase("gzip")) {
// Only trust content-length header if we understand
// the encoding -- identity or gzip
- progress.setLengthComputable(true);
- progress.setTotal(connection.getContentLength());
+ if (connection.getContentLength() != -1) {
+ progress.setLengthComputable(true);
+ progress.setTotal(connection.getContentLength());
+ }
}
inputStream = getInputStream(connection);
}