1
0
mirror of https://github.com/SKCraft/Launcher.git synced 2025-02-19 02:11:37 +01:00

Fix potential NPE with partial redownloads if connection never completes

This commit is contained in:
Henry Le Grys 2021-03-31 19:14:17 +01:00
parent c3b1e51a51
commit f7bbe82dfb

View File

@ -352,6 +352,10 @@ public class HttpRequest implements Closeable, ProgressObservable {
} }
public Optional<PartialDownloadInfo> canRetryPartial() { public Optional<PartialDownloadInfo> canRetryPartial() {
if (conn == null) {
return Optional.empty();
}
if ("bytes".equals(conn.getHeaderField("Accept-Ranges"))) { if ("bytes".equals(conn.getHeaderField("Accept-Ranges"))) {
return Optional.of(new PartialDownloadInfo(contentLength, readBytes)); return Optional.of(new PartialDownloadInfo(contentLength, readBytes));
} }