Browse Source

关闭client

tags/24080901
CMM 1 year ago
parent
commit
707108083d
1 changed files with 7 additions and 5 deletions
  1. +7
    -5
      pmapi/src/main/java/com/ningdatech/pmapi/irs/sign/IRSAPIRequest.java

+ 7
- 5
pmapi/src/main/java/com/ningdatech/pmapi/irs/sign/IRSAPIRequest.java View File

@@ -6,6 +6,7 @@ import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.util.StrPool;
import com.ningdatech.pmapi.irs.config.IrsSealPlatformProperties;
import com.ningdatech.pmapi.todocenter.model.dto.SignReqDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
@@ -34,7 +35,7 @@ import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
public class IRSAPIRequest {

/**
@@ -121,21 +122,22 @@ public class IRSAPIRequest {
.setSocketTimeout(5000)
.build();
// 通过 HttpClientBuilder 的 custom() 方法创建自定义的 HttpClient
HttpClient customHttpClient = HttpClients.custom()
CloseableHttpClient customHttpClient = HttpClients.custom()
.setDefaultRequestConfig(requestConfig)
.build();
HttpResponse res = customHttpClient.execute(req);
int statusCode = res.getStatusLine().getStatusCode();
System.out.println(statusCode);
log.info(String.valueOf(statusCode));
if (200 != statusCode) {
System.out.println(statusCode);
log.info(String.valueOf(statusCode));
}
// 获取响应
InputStream in = res.getEntity().getContent();

byte[] resp = readStream(in);
String strRes = new String(resp, StandardCharsets.UTF_8);
System.out.println(strRes);
log.info(strRes);
customHttpClient.close();
return strRes;
}



Loading…
Cancel
Save