diff --git a/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java b/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java index 940f9c79..e50a944e 100644 --- a/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +++ b/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java @@ -224,7 +224,10 @@ public void downloadPackage(JSONObject updatePackage, String expectedBundleFileN progressCallback.call(new DownloadProgress(totalBytes, receivedBytes)); } - if (totalBytes != receivedBytes) { + // getContentLength() returns -1 when the response has no Content-Length (e.g. a proxy + // re-chunked it), so only compare when the length is known. A truncated chunked + // response still fails with an IOException in the read loop above. + if (totalBytes >= 0 && totalBytes != receivedBytes) { throw new CodePushUnknownException("Received " + receivedBytes + " bytes, expected " + totalBytes); }