注释掉域名解析代码、修改.gitignore文件(添加忽略misc.xml文件)
This commit is contained in:
@ -4,7 +4,6 @@ import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.gh.common.util.HttpdnsUtils;
|
||||
import com.gh.common.util.Trace;
|
||||
import com.gh.common.util.Utils;
|
||||
|
||||
@ -25,7 +24,7 @@ public class DownloadThread extends Thread {
|
||||
private DownloadListener listener;
|
||||
private DownloadStatus status;
|
||||
private Context context;
|
||||
private boolean getNewurlSuccess = false;
|
||||
// private boolean getNewurlSuccess = false;
|
||||
|
||||
public DownloadThread(Context context, DownloadEntry entry,
|
||||
DownloadListener listener) {
|
||||
@ -55,20 +54,20 @@ public class DownloadThread extends Thread {
|
||||
}
|
||||
|
||||
//Httpdns替换地址
|
||||
String newUrl = HttpdnsUtils.getUrls(context, entry.getUrl());
|
||||
if (newUrl == null) {
|
||||
newUrl = entry.getUrl();
|
||||
getNewurlSuccess = false;
|
||||
Utils.log("HttpDnsService::获取新地址失败,用原地址进行下载,原地址为::"+newUrl);
|
||||
} else {
|
||||
getNewurlSuccess = true;
|
||||
Utils.log("HttpDnsService::获取新地址成功,目标地址为::"+newUrl);
|
||||
}
|
||||
// String newUrl = HttpdnsUtils.getUrls(context, entry.getUrl());
|
||||
// if (newUrl == null) {
|
||||
// newUrl = entry.getUrl();
|
||||
// getNewurlSuccess = false;
|
||||
// Utils.log("HttpDnsService::获取新地址失败,用原地址进行下载,原地址为::"+newUrl);
|
||||
// } else {
|
||||
// getNewurlSuccess = true;
|
||||
// Utils.log("HttpDnsService::获取新地址成功,目标地址为::"+newUrl);
|
||||
// }
|
||||
|
||||
URL url = new URL(entry.getUrl());
|
||||
// HttpURLConnection connection = (HttpURLConnection) url
|
||||
// .openConnection();
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(newUrl).openConnection();
|
||||
HttpURLConnection connection = (HttpURLConnection) url
|
||||
.openConnection();
|
||||
// HttpURLConnection connection = (HttpURLConnection) new URL(newUrl).openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setConnectTimeout(CONNECT_TIME);
|
||||
connection.setReadTimeout(READ_TIME);
|
||||
@ -76,10 +75,10 @@ public class DownloadThread extends Thread {
|
||||
"bytes=" + targetFile.length() + "-");
|
||||
|
||||
//获取新地址成功,设置HTTP请求头Host域
|
||||
if (getNewurlSuccess &&newUrl.endsWith(".apk") ){
|
||||
//非.apk,结尾的下载地址不需要加请求头Host域
|
||||
connection.setRequestProperty("Host", url.getHost());
|
||||
}
|
||||
// if (getNewurlSuccess && newUrl.endsWith(".apk") ){
|
||||
// //非.apk,结尾的下载地址不需要加请求头Host域
|
||||
// connection.setRequestProperty("Host", url.getHost());
|
||||
// }
|
||||
|
||||
//设置自动重定向
|
||||
connection.setInstanceFollowRedirects(true);
|
||||
@ -100,10 +99,10 @@ public class DownloadThread extends Thread {
|
||||
connection.setReadTimeout(READ_TIME);
|
||||
connection.setRequestProperty("RANGE",
|
||||
"bytes=" + targetFile.length() + "-");
|
||||
if (getNewurlSuccess &&newUrl.endsWith(".apk") ){
|
||||
//非.apk,结尾的下载地址不需要加请求头Host域
|
||||
connection.setRequestProperty("Host", url.getHost());
|
||||
}
|
||||
// if (getNewurlSuccess && newUrl.endsWith(".apk") ){
|
||||
// //非.apk,结尾的下载地址不需要加请求头Host域
|
||||
// connection.setRequestProperty("Host", url.getHost());
|
||||
// }
|
||||
//设置自动重定向
|
||||
connection.setInstanceFollowRedirects(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user