Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 68a6606

Browse files
committed
Merge pull request #292 from rikuayanokozy/master
check expectedContentLength greater than zero before assert
2 parents bd09373 + 48a49b9 commit 68a6606

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

ios/CodePush/CodePushDownloadHandler.m

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,15 @@ - (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error
9090
}
9191

9292
-(void)connectionDidFinishLoading:(NSURLConnection *)connection {
93-
// We should have received all of the bytes if this is called.
94-
assert(self.receivedContentLength == self.expectedContentLength);
95-
93+
// expectedContentLength might be -1 when NSURLConnection don't know the length(e.g. response encode with gzip)
94+
if (self.expectedContentLength > 0) {
95+
// We should have received all of the bytes if this is called.
96+
assert(self.receivedContentLength == self.expectedContentLength);
97+
}
98+
9699
[self.outputFileStream close];
97100
BOOL isZip = _header[0] == 'P' && _header[1] == 'K' && _header[2] == 3 && _header[3] == 4;
98101
self.doneCallback(isZip);
99102
}
100103

101-
@end
104+
@end

0 commit comments

Comments
 (0)