https忽略证书认证
This commit is contained in:
@ -3,6 +3,7 @@ package com.gh.download;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.gh.common.util.HttpsUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
|
||||
import org.apache.http.HttpStatus;
|
||||
@ -53,7 +54,15 @@ public class DownloadThread extends Thread {
|
||||
}
|
||||
|
||||
URL url = new URL(entry.getUrl());
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
Utils.log("url = " + entry.getUrl());
|
||||
|
||||
HttpURLConnection connection = null;
|
||||
if ("https".equals(url.getProtocol())) {
|
||||
connection = HttpsUtils.getHttpsURLConnection(url);
|
||||
} else {
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
}
|
||||
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setConnectTimeout(CONNECT_TIME);
|
||||
connection.setReadTimeout(READ_TIME);
|
||||
@ -63,8 +72,9 @@ public class DownloadThread extends Thread {
|
||||
"startPosition-->" + targetFile.length());
|
||||
//设置自动重定向
|
||||
connection.setInstanceFollowRedirects(true);
|
||||
|
||||
|
||||
int code = connection.getResponseCode();
|
||||
Utils.log("code = " +code);
|
||||
if (code == HttpStatus.SC_MOVED_PERMANENTLY
|
||||
|| code == HttpStatus.SC_MOVED_TEMPORARILY) {
|
||||
//未自动重定向
|
||||
|
||||
Reference in New Issue
Block a user