Compare commits
2 Commits
a5f477ad9d
...
a66422b667
Author | SHA1 | Date |
---|---|---|
ic_excellent | a66422b667 | |
ic_excellent | 3ed657ebec |
|
@ -177,6 +177,49 @@ public class ZennerUtil {
|
|||
return result;
|
||||
}
|
||||
|
||||
// public static String httpsGet(String baseUrl,String encoderNum) {
|
||||
// BufferedReader in = null;
|
||||
// BaseBean baseBean = new BaseBean();
|
||||
// try {
|
||||
// SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
|
||||
// javax.net.ssl.TrustManager[] truset = new javax.net.ssl.TrustManager[1];
|
||||
// javax.net.ssl.TrustManager tm = new DefaultTmForAllist();
|
||||
// truset[0] = tm;
|
||||
// sslContext.init(null, truset, null);
|
||||
// SSLSocketFactory factory = sslContext.getSocketFactory();
|
||||
// URL u = new URL(baseUrl);
|
||||
// HttpsURLConnection huconn = (HttpsURLConnection) u.openConnection();
|
||||
// huconn.setSSLSocketFactory(factory);
|
||||
// huconn.setRequestProperty("Authorization","Basic " + encoderNum);
|
||||
// StringBuilder result = new StringBuilder();
|
||||
// huconn.connect();
|
||||
//// baseBean.writeLog("httpsGet execute baseUrl..1." + baseUrl);
|
||||
// in = new BufferedReader(new InputStreamReader(huconn.getInputStream(), "UTF-8"));
|
||||
// String line;
|
||||
// while ((line = in.readLine()) != null) {
|
||||
// result.append(line);
|
||||
// }
|
||||
// if (in != null) {
|
||||
// in.close();
|
||||
// }
|
||||
//// baseBean.writeLog("httpsGet execute result..1." + result.toString());
|
||||
// // 打印返回结果
|
||||
// return result.toString();
|
||||
// } catch (Exception e) {
|
||||
// baseBean.writeLog("httpsGet execute exception...message:" + e.getMessage());
|
||||
// if (in != null) {
|
||||
// try {
|
||||
// in.close();
|
||||
// } catch (IOException ioException) {
|
||||
// ioException.printStackTrace();
|
||||
// baseBean.writeLog("关闭报错");
|
||||
// baseBean.writeLog(ioException.getMessage());
|
||||
// }
|
||||
// }
|
||||
// return "";
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public static String httpGet(String baseUrl){
|
||||
String url = baseUrl;
|
||||
|
@ -200,6 +243,38 @@ public class ZennerUtil {
|
|||
}
|
||||
}
|
||||
|
||||
// public static String httpsPost(String httpUrl, String content) throws Exception {
|
||||
// BufferedReader in = null;
|
||||
// SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
|
||||
// javax.net.ssl.TrustManager [] truset = new javax.net.ssl.TrustManager[1];
|
||||
// javax.net.ssl.TrustManager tm = new DefaultTmForAllist();
|
||||
// truset[0] = tm;
|
||||
// sslContext.init(null,truset,null);
|
||||
// SSLSocketFactory factory = sslContext.getSocketFactory();
|
||||
////https://blog.csdn.net/pk5454754/article/details/80092974?utm_medium=distribute.pc_relevant_download.none-task-blog-baidujs-1.nonecase&depth_1-utm_source=distribute.pc_relevant_download.none-task-blog-baidujs-1.nonecase
|
||||
// URL u = new URL(httpUrl);
|
||||
// HttpsURLConnection conn = (HttpsURLConnection) u.openConnection();
|
||||
// conn.setDoOutput(true);
|
||||
// conn.addRequestProperty("connection", "Keep-Alive");
|
||||
// conn.setRequestMethod("POST");
|
||||
// conn.setSSLSocketFactory(factory);
|
||||
// StringBuilder result = new StringBuilder();
|
||||
// conn.connect();
|
||||
// DataOutputStream out = new DataOutputStream(conn.getOutputStream());
|
||||
// out.write(content.getBytes("utf-8"));
|
||||
// // 刷新、关闭
|
||||
// out.flush();
|
||||
// out.close();
|
||||
// in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
|
||||
// String line;
|
||||
// while ((line = in.readLine()) != null) {
|
||||
// result.append(line);
|
||||
// }
|
||||
// if (in != null) {
|
||||
// in.close();
|
||||
// }
|
||||
// return result.toString();
|
||||
// }
|
||||
|
||||
public static String httpPostForXwwwForm(String httpUrl, Map<String, String> headParams, Map<String, String> paramsMap){
|
||||
String result = "";
|
||||
|
|
Loading…
Reference in New Issue