Skip to content

Commit 65e3fa1

Browse files
authored
fix issues #352
使用ApacheHttpClientAdapter 发送post请求时指定ContentType参数为UTF-8,解决微信客户端接收的时候中文乱码,返回验签校验失败的问题
1 parent c3ddd87 commit 65e3fa1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

core/src/main/java/com/wechat/pay/java/core/http/apache/ApacheHttpClientAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ private HttpEntity buildApacheHttpEntity(
104104
if (wechatPayRequestBody == null) {
105105
return new StringEntity("", "");
106106
}
107-
107+
// 指定ContentType参数为UTF-8, fix issues #352
108108
if (wechatPayRequestBody instanceof JsonRequestBody) {
109109
return new StringEntity(
110110
((JsonRequestBody) wechatPayRequestBody).getBody(),
111-
ContentType.create(wechatPayRequestBody.getContentType()));
111+
ContentType.create(wechatPayRequestBody.getContentType(),"UTF-8"));
112112
}
113113
if (wechatPayRequestBody instanceof FileRequestBody) {
114114
FileRequestBody fileRequestBody = (FileRequestBody) wechatPayRequestBody;

0 commit comments

Comments
 (0)