|
@@ -30,7 +30,10 @@ public class ViewController extends Controller {
|
|
|
|
|
|
private static final MediaType JSON_CODE = MediaType.get("application/json; charset=utf-8");
|
|
|
|
|
|
- private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient();
|
|
|
+ private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient.Builder()
|
|
|
+ .sslSocketFactory(SSLSocketClient.getSSLSocketFactory(), SSLSocketClient.getX509TrustManager())
|
|
|
+ .hostnameVerifier(SSLSocketClient.getHostnameVerifier())
|
|
|
+ .build();
|
|
|
|
|
|
/**
|
|
|
* 在被连接数据库执行sql语句
|
|
@@ -69,11 +72,6 @@ public class ViewController extends Controller {
|
|
|
public static String postWithParameters(String url, Map<String, String> map) {
|
|
|
|
|
|
|
|
|
- OkHttpClient client = new OkHttpClient.Builder()
|
|
|
- .sslSocketFactory(SSLSocketClient.getSSLSocketFactory(), SSLSocketClient.getX509TrustManager())
|
|
|
- .hostnameVerifier(SSLSocketClient.getHostnameVerifier())
|
|
|
- .build();
|
|
|
-
|
|
|
|
|
|
FormBody.Builder formbody = new FormBody.Builder();
|
|
|
|
|
@@ -87,7 +85,7 @@ public static String postWithParameters(String url, Map<String, String> map) {
|
|
|
.post(requestBody)
|
|
|
.build();
|
|
|
|
|
|
- try (Response response = client.newCall(request).execute()) {
|
|
|
+ try (Response response = OKHTTP_CLIENT.newCall(request).execute()) {
|
|
|
if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
|
|
|
String content = response.body().string();
|
|
|
return content;
|