From 47051bdf313610451c2715b46266e3c35e902b50 Mon Sep 17 00:00:00 2001 From: SynchPj <46849861+SynchPj@users.noreply.github.com> Date: Wed, 14 May 2025 11:54:30 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20#3586=20=E3=80=90=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E3=80=91=E4=BF=AE=E5=A4=8D=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=8E=A5=E5=8F=A3=E4=BD=BF=E7=94=A8POST?= =?UTF-8?q?=E8=AF=B7=E6=B1=82Content-Type=E4=B8=8D=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=AD=BE=E5=90=8D=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wxpay/service/impl/WxPayServiceApacheHttpImpl.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 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 0e06c6c3e..145582b7f 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 @@ -65,7 +65,7 @@ public class WxPayServiceApacheHttpImpl extends BaseWxPayServiceImpl { httpPost.releaseConnection(); } } catch (Exception e) { - this.logError( url, requestStr, e); + this.logError(url, requestStr, e); wxApiData.set(new WxPayApiData(url, requestStr, null, e.getMessage())); throw new WxPayException(e.getMessage(), e); } @@ -170,8 +170,6 @@ public class WxPayServiceApacheHttpImpl extends BaseWxPayServiceImpl { @Override public String postV3(String url, HttpPost httpPost) throws WxPayException { - String serialNumber = getWechatPaySerial(getConfig()); - httpPost.addHeader(WECHAT_PAY_SERIAL, serialNumber); return this.requestV3(url, httpPost); } @@ -264,8 +262,11 @@ public class WxPayServiceApacheHttpImpl extends BaseWxPayServiceImpl { private void configureRequest(HttpRequestBase request) { String serialNumber = getWechatPaySerial(getConfig()); + String method = request.getMethod(); request.addHeader(ACCEPT, APPLICATION_JSON); - request.addHeader(CONTENT_TYPE, APPLICATION_JSON); + if (!method.equals("POST")) { + request.addHeader(CONTENT_TYPE, APPLICATION_JSON); + } request.addHeader(WECHAT_PAY_SERIAL, serialNumber); request.setConfig(RequestConfig.custom()