From c3829a8d7983270fd5cb0a7d6c480e385ef4fe28 Mon Sep 17 00:00:00 2001 From: Ido Ben-Hur Date: Thu, 8 Dec 2022 21:02:59 +0200 Subject: [PATCH] OpenDelta: Download: Match HTTP response with expectation --- src/eu/chainfire/opendelta/Download.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/eu/chainfire/opendelta/Download.java b/src/eu/chainfire/opendelta/Download.java index 1c469b1..854119b 100644 --- a/src/eu/chainfire/opendelta/Download.java +++ b/src/eu/chainfire/opendelta/Download.java @@ -308,9 +308,14 @@ public class Download { urlConnection.setRequestProperty("Range", "bytes=" + offset + "-"); urlConnection.connect(); int code = urlConnection.getResponseCode(); - if (code != HttpsURLConnection.HTTP_OK - && code != HttpsURLConnection.HTTP_PARTIAL) { - Logger.d("response: %d", code); + if (offset > 0 && code != HttpsURLConnection.HTTP_PARTIAL) { + Logger.d("response: %d expected: %d", code, + HttpsURLConnection.HTTP_PARTIAL); + return null; + } + if (offset == 0 && code != HttpsURLConnection.HTTP_OK) { + Logger.d("response: %d expected: %d", code, + HttpsURLConnection.HTTP_OK); return null; } return urlConnection;