From afa8fc57084c423218c6816b710dfb2f0b87ea89 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期四, 14 十一月 2024 15:55:48 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/HttpsRequest.java | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 43 insertions(+), 1 deletions(-) diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/HttpsRequest.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/HttpsRequest.java index 70901d9..3a48ae1 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/HttpsRequest.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/common/utils/HttpsRequest.java @@ -1,5 +1,6 @@ package com.iailab.module.data.common.utils; +import com.alibaba.fastjson.JSON; import lombok.extern.slf4j.Slf4j; import org.apache.http.Header; import org.apache.http.HttpEntity; @@ -122,13 +123,54 @@ * doPost * * @param url + * @param jsonStr + * @param date + * @param charset + * @return + */ + public String doPost(String url, String jsonStr, String date, String charset) { + org.apache.http.client.HttpClient httpClient = null; + HttpPost httpPost = null; + String result = null; + try { + httpClient = new SSLClient(); + StringBuilder sb = new StringBuilder(); + sb.append(url); + sb.append("/"); + sb.append(date); + log.info("url=====" + sb.toString()); + httpPost = new HttpPost(sb.toString()); + //设置参数 + httpPost.addHeader("Content-Type", "application/json;charset=UTF-8"); + StringEntity stringEntity = new StringEntity(jsonStr); + stringEntity.setContentEncoding("UTF-8"); + stringEntity.setContentType("application/json"); + httpPost.setEntity(stringEntity); + HttpResponse response = httpClient.execute(httpPost); + if (response != null) { + HttpEntity resEntity = response.getEntity(); + if (resEntity != null) { + result = EntityUtils.toString(resEntity, charset); + } + } + } catch (Exception ex) { + // ex.printStackTrace(); + log.info("doPost失败,url=" + url); + } + return result; + } + + /** + * doPost + * + * @param url * @param map * @param json * @param charset * @param token * @return */ - public String doPost(String url, Map<String, String> map, String json, String charset, String token) { + public String doPostForToken(String url, Map<String, String> map, String json, String charset, String token) { org.apache.http.client.HttpClient httpClient = null; HttpPost httpPost = null; String result = null; -- Gitblit v1.9.3