From 335ae799e9a949ef35a5d7420d8aef33af5c16f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliv=C3=A9r=20Falvai?= Date: Thu, 5 Nov 2026 10:30:57 +0100 Subject: [PATCH] fix(android): accept downloads without Content-Length Co-Authored-By: Claude Sonnet 5.5 --- .../com/microsoft/codepush/react/CodePushUpdateManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); }