From 0c515e7b8e3c1c15c615cc831ef3fdb09ea5265e Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期五, 10 十月 2025 10:25:17 +0800
Subject: [PATCH] 修改BUG

---
 ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java
index f0713bc..859672d 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java
@@ -106,11 +106,23 @@
             httpMethod.setRequestEntity(entity);
 
             int resultCode = httpClient.executeMethod(httpMethod);
+            // 鑾峰彇鍝嶅簲澶寸殑瀛楃缂栫爜
+            String contentType = httpMethod.getResponseHeader("Content-Type") == null ?
+                    null : httpMethod.getResponseHeader("Content-Type").getValue();
+            String charset = "UTF-8"; // 榛樿浣跨敤UTF-8
+
+            if (contentType != null && contentType.contains("charset=")) {
+                String[] parts = contentType.split("charset=");
+                if (parts.length > 1) {
+                    charset = parts[1].split(";")[0].trim();
+                }
+            }
+
             InputStream inputStream = httpMethod.getResponseBodyAsStream();
             if (inputStream == null) {
                 throw new HttpRequestException(RESPONSE_NULL_ERROR_CODE, "鍝嶅簲涓簄ull");
             }
-            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
+            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream,charset));
             StringBuffer stringBuffer = new StringBuffer();
             String str = "";
             while ((str = reader.readLine()) != null) {

--
Gitblit v1.9.3