Fix issue #449 - Handle 302 for media

This commit is contained in:
Thomas 2020-07-06 15:02:25 +02:00
parent 8be1e8e2e7
commit 717fdcaea1
1 changed files with 3 additions and 3 deletions

View File

@ -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<String, List<String>> map = httpsURLConnection.getHeaderFields();
for (Map.Entry<String, List<String>> 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();
}