Fix issue #449 - Handle 302 for media
This commit is contained in:
parent
8be1e8e2e7
commit
717fdcaea1
|
@ -236,7 +236,7 @@ public class HttpsConnection {
|
||||||
httpsURLConnection.setInstanceFollowRedirects(false);
|
httpsURLConnection.setInstanceFollowRedirects(false);
|
||||||
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
||||||
httpsURLConnection.setRequestMethod("HEAD");
|
httpsURLConnection.setRequestMethod("HEAD");
|
||||||
if (httpsURLConnection.getResponseCode() == 301) {
|
if (httpsURLConnection.getResponseCode() == 301 || httpsURLConnection.getResponseCode() == 302) {
|
||||||
Map<String, List<String>> map = httpsURLConnection.getHeaderFields();
|
Map<String, List<String>> map = httpsURLConnection.getHeaderFields();
|
||||||
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
|
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
|
||||||
if (entry.toString().toLowerCase().startsWith("location")) {
|
if (entry.toString().toLowerCase().startsWith("location")) {
|
||||||
|
@ -809,7 +809,7 @@ public class HttpsConnection {
|
||||||
httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
int responseCode = httpsURLConnection.getResponseCode();
|
int responseCode = httpsURLConnection.getResponseCode();
|
||||||
// always check HTTP response code first
|
// always check HTTP response code first
|
||||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
if (responseCode >= 200 && responseCode < 400) {
|
||||||
// opens input stream from the HTTP connection
|
// opens input stream from the HTTP connection
|
||||||
return httpsURLConnection.getInputStream();
|
return httpsURLConnection.getInputStream();
|
||||||
}
|
}
|
||||||
|
@ -830,7 +830,7 @@ public class HttpsConnection {
|
||||||
httpURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
httpURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
int responseCode = httpURLConnection.getResponseCode();
|
int responseCode = httpURLConnection.getResponseCode();
|
||||||
// always check HTTP response code first
|
// always check HTTP response code first
|
||||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
if (responseCode >= 200 && responseCode < 400) {
|
||||||
// opens input stream from the HTTP connection
|
// opens input stream from the HTTP connection
|
||||||
return httpURLConnection.getInputStream();
|
return httpURLConnection.getInputStream();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue