refactor: 在请求头Content-Type中声明字符集UTF-8,避免中文乱码

This commit is contained in:
felord.cn
2021-02-26 00:14:15 +08:00
committed by felord.cn
parent 467f4d74ae
commit 095fff5c69

View File

@@ -226,7 +226,8 @@ public class WechatPayClient {
httpHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
// for upload
if (Objects.isNull(httpHeaders.getContentType())) {
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
// 避免出现因为中文导致的 HttpRetryException
httpHeaders.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
}
httpHeaders.add("Authorization", authorization);
httpHeaders.add("User-Agent", "X-Pay-Service");