Use internal library for networking

This commit is contained in:
topjohnwu
2018-12-12 05:51:45 -05:00
parent eab74ef06b
commit 59b1e63bdf
29 changed files with 552 additions and 365 deletions

View File

@ -1,30 +0,0 @@
package com.topjohnwu.magisk.utils;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
public class WebService {
public static HttpURLConnection request(String address) throws IOException {
URL url = new URL(address);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(15000);
conn.setConnectTimeout(15000);
conn.connect();
return conn;
}
public static HttpURLConnection mustRequest(String address) throws IOException {
HttpURLConnection conn;
do {
conn = WebService.request(address);
int total = conn.getContentLength();
if (total < 0)
conn.disconnect();
else
break;
} while (true);
return conn;
}
}