CB-5762 android: Fix lengthComputable set wrong for gzip downloads

Gzip + no Content-Length header should be lengthComputable=false
This commit is contained in:
Andrew Grieve
2014-01-10 11:45:59 -05:00
parent 613ee821df
commit 3c1ff16064
+2
View File
@@ -760,9 +760,11 @@ public class FileTransfer extends CordovaPlugin {
if (connection.getContentEncoding() == null || connection.getContentEncoding().equalsIgnoreCase("gzip")) { if (connection.getContentEncoding() == null || connection.getContentEncoding().equalsIgnoreCase("gzip")) {
// Only trust content-length header if we understand // Only trust content-length header if we understand
// the encoding -- identity or gzip // the encoding -- identity or gzip
if (connection.getContentLength() != -1) {
progress.setLengthComputable(true); progress.setLengthComputable(true);
progress.setTotal(connection.getContentLength()); progress.setTotal(connection.getContentLength());
} }
}
inputStream = getInputStream(connection); inputStream = getInputStream(connection);
} }