From c91a5a8e22e1d66863217c3492f41e255c3d15a5 Mon Sep 17 00:00:00 2001 From: SynchPj <46849861+SynchPj@users.noreply.github.com> Date: Tue, 13 May 2025 12:49:46 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E3=80=90=E5=BE=AE=E4=BF=A1=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E3=80=91=E4=BF=AE=E5=A4=8D=E8=BF=9E=E6=8E=A5=E6=B1=A0?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/WxPayServiceApacheHttpImpl.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java index dcd70b523..0e06c6c3e 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java @@ -105,8 +105,8 @@ public class WxPayServiceApacheHttpImpl extends BaseWxPayServiceImpl { } private String requestV3(String url, String requestStr, HttpRequestBase httpRequestBase) throws WxPayException { - try (CloseableHttpClient httpClient = this.createApiV3HttpClient(); - CloseableHttpResponse response = httpClient.execute(httpRequestBase)) { + CloseableHttpClient httpClient = this.createApiV3HttpClient(); + try (CloseableHttpResponse response = httpClient.execute(httpRequestBase)) { //v3已经改为通过状态码判断200 204 成功 int statusCode = response.getStatusLine().getStatusCode(); //post方法有可能会没有返回值的情况 @@ -142,8 +142,8 @@ public class WxPayServiceApacheHttpImpl extends BaseWxPayServiceImpl { public String postV3WithWechatpaySerial(String url, String requestStr) throws WxPayException { HttpPost httpPost = this.createHttpPost(url, requestStr); this.configureRequest(httpPost); - try (CloseableHttpClient httpClient = this.createApiV3HttpClient(); - CloseableHttpResponse response = httpClient.execute(httpPost)) { + CloseableHttpClient httpClient = this.createApiV3HttpClient(); + try (CloseableHttpResponse response = httpClient.execute(httpPost)) { //v3已经改为通过状态码判断200 204 成功 int statusCode = response.getStatusLine().getStatusCode(); String responseString = "{}"; @@ -178,9 +178,8 @@ public class WxPayServiceApacheHttpImpl extends BaseWxPayServiceImpl { @Override public String requestV3(String url, HttpRequestBase httpRequest) throws WxPayException { this.configureRequest(httpRequest); - - try (CloseableHttpClient httpClient = this.createApiV3HttpClient(); - CloseableHttpResponse response = httpClient.execute(httpRequest)) { + CloseableHttpClient httpClient = this.createApiV3HttpClient(); + try (CloseableHttpResponse response = httpClient.execute(httpRequest)) { //v3已经改为通过状态码判断200 204 成功 int statusCode = response.getStatusLine().getStatusCode(); //post方法有可能会没有返回值的情况 @@ -223,11 +222,9 @@ public class WxPayServiceApacheHttpImpl extends BaseWxPayServiceImpl { @Override public InputStream downloadV3(String url) throws WxPayException { HttpGet httpGet = new WxPayV3DownloadHttpGet(url); - httpGet.addHeader(ACCEPT, ContentType.WILDCARD.getMimeType()); - String serialNumber = getWechatPaySerial(getConfig()); - httpGet.addHeader(WECHAT_PAY_SERIAL, serialNumber); - try (CloseableHttpClient httpClient = this.createApiV3HttpClient(); - CloseableHttpResponse response = httpClient.execute(httpGet)) { + this.configureRequest(httpGet); + CloseableHttpClient httpClient = this.createApiV3HttpClient(); + try (CloseableHttpResponse response = httpClient.execute(httpGet)) { //v3已经改为通过状态码判断200 204 成功 int statusCode = response.getStatusLine().getStatusCode(); Header contentType = response.getFirstHeader(HttpHeaders.CONTENT_TYPE);