Repository navigation
fix(android): accept downloads without Content-Length - #109
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
A critical validation gap allows an empty HTTP 200 response without Content-Length to be staged as the next app bundle without hash or signature verification.
1 open issue
What changed in this PR
Fixes #108 by allowing Android CodePush downloads without a Content-Length header, including responses re-chunked by proxies.
Changes:
- Compares received and expected bytes only when the expected length is known.
- Documents why unknown lengths are accepted and truncated chunked responses still fail during reading.
- Leaves JavaScript progress reporting unchanged.
| File | Description |
|---|---|
android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java |
Guards the download-length check and adds an explanatory comment. |
Review effort: Balanced
miklosboros
approved these changes
Nov 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #108.
Problem
Android rejects a fully downloaded update with
Received N bytes, expected -1when the response has noContent-Length.HttpURLConnection.getContentLength()returns-1in that case, and the completeness check compares it against the byte count. Proxies that re-chunk responses trigger it, so it depends on the device's network path.Change
Only compare received and expected bytes when the length is known. This matches iOS, which already skips the check when the expected length is unknown.
Why this is safe
HttpURLConnectionthrow anIOExceptionin the read loop, so truncation still fails.Content-Lengththat doesn't match is still rejected.Out of scope
Progress events still report
totalBytes: -1for these responses, as they did before. The JS side is not touched here.🤖 Generated with Claude Code