From 717fdcaea12839bb22eb257254c783e59cf4c852 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 6 Jul 2020 15:02:25 +0200 Subject: [PATCH] Fix issue #449 - Handle 302 for media --- .../java/app/fedilab/android/client/HttpsConnection.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/client/HttpsConnection.java b/app/src/main/java/app/fedilab/android/client/HttpsConnection.java index cd3c820ea..f5145ad73 100644 --- a/app/src/main/java/app/fedilab/android/client/HttpsConnection.java +++ b/app/src/main/java/app/fedilab/android/client/HttpsConnection.java @@ -236,7 +236,7 @@ public class HttpsConnection { httpsURLConnection.setInstanceFollowRedirects(false); httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance)); httpsURLConnection.setRequestMethod("HEAD"); - if (httpsURLConnection.getResponseCode() == 301) { + if (httpsURLConnection.getResponseCode() == 301 || httpsURLConnection.getResponseCode() == 302) { Map> map = httpsURLConnection.getHeaderFields(); for (Map.Entry> entry : map.entrySet()) { if (entry.toString().toLowerCase().startsWith("location")) { @@ -809,7 +809,7 @@ public class HttpsConnection { httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT); int responseCode = httpsURLConnection.getResponseCode(); // always check HTTP response code first - if (responseCode == HttpURLConnection.HTTP_OK) { + if (responseCode >= 200 && responseCode < 400) { // opens input stream from the HTTP connection return httpsURLConnection.getInputStream(); } @@ -830,7 +830,7 @@ public class HttpsConnection { httpURLConnection.setRequestProperty("User-Agent", USER_AGENT); int responseCode = httpURLConnection.getResponseCode(); // always check HTTP response code first - if (responseCode == HttpURLConnection.HTTP_OK) { + if (responseCode >= 200 && responseCode < 400) { // opens input stream from the HTTP connection return httpURLConnection.getInputStream(); }