Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.wechat.pay.java.core.http.OriginalResponse;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.http.Header;
Expand Down Expand Up @@ -104,11 +105,11 @@ private HttpEntity buildApacheHttpEntity(
if (wechatPayRequestBody == null) {
return new StringEntity("", "");
}

// 指定ContentType参数为UTF-8, fix issues #352
if (wechatPayRequestBody instanceof JsonRequestBody) {
return new StringEntity(
((JsonRequestBody) wechatPayRequestBody).getBody(),
ContentType.create(wechatPayRequestBody.getContentType()));
ContentType.create(wechatPayRequestBody.getContentType(), StandardCharsets.UTF_8));
}
if (wechatPayRequestBody instanceof FileRequestBody) {
FileRequestBody fileRequestBody = (FileRequestBody) wechatPayRequestBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.apache.http.Header;
Expand Down Expand Up @@ -253,7 +254,7 @@ public void process(org.apache.http.HttpRequest request, HttpContext context)
HttpEntity entity =
new StringEntity(
JSON_REQUEST_BODY.getBody(),
ContentType.create(JSON_REQUEST_BODY.getContentType()));
ContentType.create(JSON_REQUEST_BODY.getContentType(), StandardCharsets.UTF_8));
Assert.assertEquals(
entity.getContentType().getValue(), reqEntity.getContentType().getValue());
Assert.assertEquals(entity.getContentLength(), reqEntity.getContentLength());
Expand Down Expand Up @@ -1057,7 +1058,7 @@ public void process(org.apache.http.HttpRequest request, HttpContext context)
HttpEntity entity =
new StringEntity(
JSON_REQUEST_BODY.getBody(),
ContentType.create(JSON_REQUEST_BODY.getContentType()));
ContentType.create(JSON_REQUEST_BODY.getContentType(), StandardCharsets.UTF_8));
Assert.assertEquals(
entity.getContentType().getValue(), reqEntity.getContentType().getValue());
Assert.assertEquals(entity.getContentLength(), reqEntity.getContentLength());
Expand Down
Loading