From 50c4dfd33c88330cea9d105949906bf6648f8841 Mon Sep 17 00:00:00 2001 From: yxuan Date: Fri, 3 Jan 2025 13:36:43 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96TripLinkHttpClient,?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vcc/util/TripLinkHttpClient.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/vcc-sdk-java/src/main/java/com/ctrip/ccard/creditcard/vcc/util/TripLinkHttpClient.java b/vcc-sdk-java/src/main/java/com/ctrip/ccard/creditcard/vcc/util/TripLinkHttpClient.java index ea70742..74cfa7f 100644 --- a/vcc-sdk-java/src/main/java/com/ctrip/ccard/creditcard/vcc/util/TripLinkHttpClient.java +++ b/vcc-sdk-java/src/main/java/com/ctrip/ccard/creditcard/vcc/util/TripLinkHttpClient.java @@ -32,6 +32,22 @@ public class TripLinkHttpClient implements HttpClient { private static final String CONTENT_TYPE_JSON_CONTENT = "application/json"; + private static Integer CONNECT_TIMEOUT = null; + private static Integer READ_TIMEOUT = null; + + public TripLinkHttpClientPref(Integer connectTimeout,Integer readTimeout) { + if(connectTimeout != null){ + CONNECT_TIMEOUT = connectTimeout; + } + if(readTimeout != null){ + READ_TIMEOUT = readTimeout; + } + + } + public TripLinkHttpClientPref() { + + } + public CallHttpResponse post(String requestJson, String url, Map header) { try { if(null == header){ @@ -85,6 +101,11 @@ private static CallHttpResponse httpsRequest(String requestUrl,String httpMethod conn.setUseCaches(false); conn.setRequestMethod(httpMethod); conn.setSSLSocketFactory(ssf); + if (null != CONNECT_TIMEOUT) + conn.setConnectTimeout(CONNECT_TIMEOUT); + if(null != READ_TIMEOUT) + conn.setReadTimeout(READ_TIMEOUT); + //设置 header if(null != header){ for(Map.Entry entry : header.entrySet()){ From b77b62919e2908aab2adfced9c5bf60403fbb047 Mon Sep 17 00:00:00 2001 From: yxuan Date: Fri, 3 Jan 2025 13:55:31 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96TripLinkHttpClient,?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ccard/creditcard/vcc/util/TripLinkHttpClient.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vcc-sdk-java/src/main/java/com/ctrip/ccard/creditcard/vcc/util/TripLinkHttpClient.java b/vcc-sdk-java/src/main/java/com/ctrip/ccard/creditcard/vcc/util/TripLinkHttpClient.java index 74cfa7f..fffb23c 100644 --- a/vcc-sdk-java/src/main/java/com/ctrip/ccard/creditcard/vcc/util/TripLinkHttpClient.java +++ b/vcc-sdk-java/src/main/java/com/ctrip/ccard/creditcard/vcc/util/TripLinkHttpClient.java @@ -35,7 +35,13 @@ public class TripLinkHttpClient implements HttpClient { private static Integer CONNECT_TIMEOUT = null; private static Integer READ_TIMEOUT = null; - public TripLinkHttpClientPref(Integer connectTimeout,Integer readTimeout) { + /** + * des: + * @param connectTimeout 毫秒 + * @param readTimeout 毫秒 + * date 2025/1/3 13:54 + */ + public TripLinkHttpClient(Integer connectTimeout,Integer readTimeout) { if(connectTimeout != null){ CONNECT_TIMEOUT = connectTimeout; } @@ -44,7 +50,7 @@ public TripLinkHttpClientPref(Integer connectTimeout,Integer readTimeout) { } } - public TripLinkHttpClientPref() { + public TripLinkHttpClient() { }