|
|
|
@@ -284,6 +284,13 @@ public class HttpUtils { |
|
|
|
return resultStr; |
|
|
|
} |
|
|
|
|
|
|
|
private static void clearProxySettings() { |
|
|
|
System.clearProperty("http.proxyHost"); |
|
|
|
System.clearProperty("http.proxyPort"); |
|
|
|
System.clearProperty("https.proxyHost"); |
|
|
|
System.clearProperty("https.proxyPort"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 向指定 URL 发送POST方法的请求 |
|
|
|
* |
|
|
|
@@ -292,6 +299,7 @@ public class HttpUtils { |
|
|
|
* @return 所代表远程资源的响应结果 |
|
|
|
*/ |
|
|
|
public static String sendPost(String url, String param) { |
|
|
|
clearProxySettings(); |
|
|
|
PrintWriter out = null; |
|
|
|
BufferedReader in = null; |
|
|
|
StringBuilder result = new StringBuilder(); |
|
|
|
@@ -306,9 +314,9 @@ public class HttpUtils { |
|
|
|
conn.setRequestProperty("contentType", "utf-8"); |
|
|
|
conn.setDoOutput(true); |
|
|
|
conn.setDoInput(true); |
|
|
|
out = new PrintWriter(conn.getOutputStream()); |
|
|
|
out.print(param); |
|
|
|
out.flush(); |
|
|
|
out = new PrintWriter(conn.getOutputStream()); |
|
|
|
out.print(param); |
|
|
|
out.flush(); |
|
|
|
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8)); |
|
|
|
String line; |
|
|
|
while ((line = in.readLine()) != null) { |
|
|
|
@@ -338,7 +346,8 @@ public class HttpUtils { |
|
|
|
return result.toString(); |
|
|
|
} |
|
|
|
|
|
|
|
public static String sendPost(String url, String param, String body){ |
|
|
|
public static String sendPost(String url, String param, String body) { |
|
|
|
clearProxySettings(); |
|
|
|
String urlNameString = url; |
|
|
|
if (StringUtils.isNotEmpty(param)) { |
|
|
|
urlNameString = url + "?" + param; |
|
|
|
|