diff --git a/.gitignore b/.gitignore index 1d019726cd..529e325cff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ /.idea +.idea/misc.xml *.iml .gradle /local.properties .DS_Store /build -/captures +/captures \ No newline at end of file diff --git a/app/src/main/java/com/gh/download/DownloadThread.java b/app/src/main/java/com/gh/download/DownloadThread.java index 6bf7d595a7..e20709cc8f 100644 --- a/app/src/main/java/com/gh/download/DownloadThread.java +++ b/app/src/main/java/com/gh/download/DownloadThread.java @@ -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); }