zhanghua
2023-12-12 bc2da7908a227c09e5cc7b6d8dab3e9c94b784a1
ycl-smoke/src/main/java/com/ycl/smoke/utils/HttpUtil.java
@@ -30,7 +30,7 @@
    private static final CloseableHttpClient httpclient = HttpClients.createDefault();
    public static String doGet(String urlPath, Map<String, Object> params)
    public static String doGet(String urlPath, Map<String, Object> params,String token)
            throws Exception {
        StringBuilder sb = new StringBuilder(urlPath);
        if (params != null && !params.isEmpty()) { // 说明有参数
@@ -54,6 +54,7 @@
        URL url = new URL(sb.toString());
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestProperty("auth", token);
        conn.setConnectTimeout(5000); // 5s超时
        conn.setRequestMethod("GET");
@@ -118,7 +119,7 @@
            //第三步:给httpPost设置JSON格式的参数
            StringEntity requestEntity = new StringEntity(json,"utf-8");
            requestEntity.setContentEncoding("UTF-8");
            httpPost.setHeader("Content-type", "application/json");
            httpPost.setHeader("Content-type", "application/x-www-form-urlencoded");
            httpPost.setHeader("Auth",token);
            httpPost.setEntity(requestEntity);