陈昶聿
2 天以前 88d4cd31fa5b197a91ed081ba1df292420af2d05
ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java
@@ -95,7 +95,26 @@
        return httpClient;
    }
    public static String postJsonRequest(String url, String request) throws HttpRequestException {
    /**
     * json的post请求(只关心是否成功,非200直接抛异常)
     *
     * @param url     请求url
     * @param request 请求报文
     * @return 固定返回true(http状态非200会抛HttpRequestException)
     */
    public static Boolean postJsonRequest(String url, String request) throws HttpRequestException {
        postJsonRequestForString(url, request);
        return true;
    }
    /**
     * json的post请求,返回响应报文内容(用于需要解析返回码的场景,如云MAS短信)
     *
     * @param url     请求url
     * @param request 请求报文
     * @return 响应报文内容
     */
    public static String postJsonRequestForString(String url, String request) throws HttpRequestException {
        Assert.hasLength(url, "请求url不能为空字符串。");
        EntityEnclosingMethod httpMethod = new PostMethod(url);
@@ -122,7 +141,7 @@
            if (inputStream == null) {
                throw new HttpRequestException(RESPONSE_NULL_ERROR_CODE, "响应为null");
            }
            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream,charset));
            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, charset));
            StringBuffer stringBuffer = new StringBuffer();
            String str = "";
            while ((str = reader.readLine()) != null) {
@@ -134,6 +153,7 @@
            if (resultCode == OK) {
                return respJson;
            } else {
                log.warn("【postJsonRequestForString】请求失败,url:{},状态码:{},响应:{}", url, resultCode, respJson);
                throw new HttpRequestException(resultCode, respJson);
            }
        } catch (UnsupportedEncodingException e) {
@@ -153,8 +173,6 @@
     * json的post请求
     *
     * @param url           请求url
     * @param reqEntity     请求头与请求体的封装
     * @param respBodyClass 响应体类型
     * @return 返回的响应结果
     */
    public static String postXmlRequest(String url, String request) throws HttpRequestException {