fix(#10717): com.alibaba.nacos.common.http.client.request.JdkHttpClientRequest.execute, when the body instanceof String, no longer call com.alibaba.nacos.common.utils.JacksonUtils.toJson to parse body. (#10718)

This commit is contained in:
blake.qiu 2023-07-02 00:02:57 +08:00 committed by GitHub
parent b0b16e3919
commit 9116aee82f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -96,7 +96,7 @@ public class JdkHttpClientRequest implements HttpClientRequest {
conn.setRequestMethod(httpMethod);
if (body != null && !"".equals(body)) {
String contentType = headers.getValue(HttpHeaderConsts.CONTENT_TYPE);
String bodyStr = JacksonUtils.toJson(body);
String bodyStr = body instanceof String ? (String) body : JacksonUtils.toJson(body);
if (MediaType.APPLICATION_FORM_URLENCODED.equals(contentType)) {
Map<String, String> map = JacksonUtils.toObj(bodyStr, HashMap.class);
bodyStr = HttpUtils.encodingParams(map, headers.getCharset());