Skip to content

Commit 6d41173

Browse files
author
JemyCheung
committed
useHttps_query
1 parent 5ed0ac2 commit 6d41173

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

library/src/main/java/com/qiniu/android/http/DnsPrefetcher.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class DnsPrefetcher {
3333

3434
public static DnsPrefetcher dnsPrefetcher = null;
3535
private static String token;
36+
private static Configuration config;
3637

3738
private static ConcurrentHashMap<String, List<InetAddress>> mConcurrentHashMap = new ConcurrentHashMap<String, List<InetAddress>>();
3839
private static List<String> mHosts = new ArrayList<String>();
@@ -74,8 +75,9 @@ public void localFetch() {
7475
}
7576

7677

77-
public DnsPrefetcher init(String token) throws UnknownHostException {
78+
public DnsPrefetcher init(String token, Configuration config) throws UnknownHostException {
7879
this.token = token;
80+
this.config = config;
7981
List<String> preHosts = preHosts();
8082
if (preHosts != null && preHosts.size() > 0)
8183
preFetch(preHosts);
@@ -242,7 +244,11 @@ ZoneInfo preQueryIndex(DnsPrefetcher.ZoneIndex index) {
242244

243245
ResponseInfo getZoneJsonSync(DnsPrefetcher.ZoneIndex index) {
244246
Client client = new Client();
245-
String address = "http://" + Config.preQueryHost + "/v2/query?ak=" + index.accessKey + "&bucket=" + index.bucket;
247+
String schema = "https://";
248+
if (!config.useHttps) {
249+
schema = "http://";
250+
}
251+
String address = schema + Config.preQueryHost + "/v2/query?ak=" + index.accessKey + "&bucket=" + index.bucket;
246252
return client.syncGet(address, null);
247253
}
248254

@@ -366,7 +372,7 @@ public static void startPrefetchDns(String token, Configuration config) {
366372
DnsPrefetcher dnsPrefetcher = null;
367373
try {
368374
recorder = new DnsCacheFile(Config.dnscacheDir);
369-
dnsPrefetcher = DnsPrefetcher.getDnsPrefetcher().init(token);
375+
dnsPrefetcher = DnsPrefetcher.getDnsPrefetcher().init(token, config);
370376
//确认预取结束后,需要更新缓存mDnsCacheKey
371377
mDnsCacheKey = dnsCacheKey;
372378
} catch (IOException e) {

0 commit comments

Comments
 (0)