新增代理
This commit is contained in:
@@ -17,7 +17,7 @@ public class HttpTools {
|
||||
private static final int HttpRequestIndex = 3;
|
||||
|
||||
public static String get(String url) {
|
||||
return http_get(url, null);
|
||||
return http_get(url, null,false);
|
||||
}
|
||||
|
||||
public static String post(final String url, final byte[] body) {
|
||||
@@ -40,10 +40,19 @@ public class HttpTools {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String http_get(String url, Map<String, String> header) {
|
||||
public static String http_get(String url, Map<String, String> header,boolean isProxy) {
|
||||
try {
|
||||
HttpURLConnection connection;
|
||||
connection = (HttpURLConnection) new URL(url).openConnection();
|
||||
Proxy proxy = null;
|
||||
if (isProxy) {
|
||||
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 7890));
|
||||
}
|
||||
|
||||
if(proxy==null) {
|
||||
connection = (HttpURLConnection) new URL(url).openConnection();
|
||||
}else{
|
||||
connection = (HttpURLConnection) new URL(url).openConnection(proxy);
|
||||
}
|
||||
return urlConnection(header, connection);
|
||||
} catch (Exception e) {
|
||||
System.err.println("error url = " + url);
|
||||
|
||||
Reference in New Issue
Block a user