| | |
| | | package cn.huge.base.common.utils; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.apache.http.HttpEntity; |
| | | import org.apache.http.NameValuePair; |
| | |
| | | * @time: 2021-11-05 16:51:48 |
| | | * @version: 1.0.0 |
| | | */ |
| | | @Slf4j |
| | | public class HttpClientUtils { |
| | | |
| | | /** |
| | |
| | | } |
| | | CloseableHttpClient closeableHttpClient = HttpClients.createDefault(); |
| | | HttpPost httpost = new HttpPost(url); |
| | | |
| | | //设置header |
| | | if (ObjectUtils.isNotEmpty(headers)) { |
| | | for (Map.Entry<String, String> entry : headers.entrySet()) { |
| | |
| | | } |
| | | //组织请求参数 |
| | | List<NameValuePair> paramList = new ArrayList <NameValuePair>(); |
| | | |
| | | if(ObjectUtils.isNotEmpty(params)){ |
| | | Set<String> keySet = params.keySet(); |
| | | for(String key : keySet) { |
| | |
| | | httpResponse.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | |
| | | } |
| | | } |
| | | try { //关闭连接、释放资源 |