package com.gkhy.exam.common.utils;
|
|
import cn.hutool.http.HttpException;
|
import cn.hutool.http.HttpRequest;
|
import cn.hutool.http.HttpUtil;
|
import com.alibaba.fastjson2.JSON;
|
import lombok.extern.slf4j.Slf4j;
|
|
import java.util.HashMap;
|
import java.util.Map;
|
|
@Slf4j
|
public class HttpUtils {
|
|
public static String sendGet(String url, Map<String, Object> queryParams){
|
Map<String, String> headers =new HashMap<>();
|
headers.put("accept","*/*");
|
headers.put("connection","Keep-Alive");
|
headers.put("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
String body="";
|
try {
|
body = HttpRequest.get(url).form(queryParams).addHeaders(headers).execute().body();
|
log.info("recv - {}",body);
|
return body;
|
}catch (HttpException e){
|
log.error("调用HttpUtils.sendGet ConnectException, url=" + url + ",param=" + JSON.toJSONString(queryParams), e);
|
}
|
return body;
|
}
|
}
|