From efb07bcec37c49228d9760794f215c8549243ad2 Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Mon, 23 Mar 2026 18:52:21 +0800
Subject: [PATCH] 1

---
 src/main/java/com/nq/utils/http/HttpClientRequest.java |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/nq/utils/http/HttpClientRequest.java b/src/main/java/com/nq/utils/http/HttpClientRequest.java
index b82a37b..a0c90cf 100644
--- a/src/main/java/com/nq/utils/http/HttpClientRequest.java
+++ b/src/main/java/com/nq/utils/http/HttpClientRequest.java
@@ -184,5 +184,49 @@
         return result;
     }
 
+    /**
+     * POST JSON 字符串,Content-Type: application/json; charset=utf-8
+     */
+    public static String doPostJsonBody(String url, String jsonBody) {
+        CloseableHttpClient httpClient = null;
+        CloseableHttpResponse httpResponse = null;
+        String result = "";
+        httpClient = HttpClients.createDefault();
+        HttpPost httpPost = new HttpPost(url);
+        RequestConfig requestConfig = RequestConfig.custom()
+                .setConnectTimeout(35000)
+                .setConnectionRequestTimeout(35000)
+                .setSocketTimeout(60000)
+                .build();
+        httpPost.setConfig(requestConfig);
+        httpPost.addHeader("Content-Type", "application/json; charset=utf-8");
+        try {
+            httpPost.setEntity(new StringEntity(jsonBody, "utf-8"));
+            httpResponse = httpClient.execute(httpPost);
+            HttpEntity entity = httpResponse.getEntity();
+            result = EntityUtils.toString(entity);
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (null != httpResponse) {
+                try {
+                    httpResponse.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (null != httpClient) {
+                try {
+                    httpClient.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return result;
+    }
+
 
 }

--
Gitblit v1.9.3