From 55f5271f893a25a7be671b24938e49976936a67b Mon Sep 17 00:00:00 2001 From: liusheng <337615773@qq.com> Date: 星期一, 29 九月 2025 18:30:00 +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