From fee8faba99f6e30cab460bbc8571ec2c2a5e17de Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期二, 21 十月 2025 14:57:46 +0800
Subject: [PATCH] 新增Orgid
---
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