liusheng
2026-10-08 0bc3fc0304d163c9e54e4e36f45f72ce1b1d59fb
ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java
@@ -395,14 +395,18 @@
            // 获取响应码
            int responseCode = connection.getResponseCode();
            log.info("postFormRequest 响应码:{},url:{}", responseCode, fullUrl);
            // 读取响应
            // 读取响应(非200时errorStream可能为null,避免NPE)
            StringBuilder response = new StringBuilder();
            if (responseCode == HttpURLConnection.HTTP_OK) {
                reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            } else {
                reader = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
            InputStream respStream = responseCode == HttpURLConnection.HTTP_OK
                    ? connection.getInputStream()
                    : connection.getErrorStream();
            if (respStream == null) {
                log.warn("postFormRequest 响应体为空,响应码:{},url:{}", responseCode, fullUrl);
                return "";
            }
            reader = new BufferedReader(new InputStreamReader(respStream));
            String line;
            while ((line = reader.readLine()) != null) {