From b8e9545c55257c5df19b20af0f956804a593df64 Mon Sep 17 00:00:00 2001 From: jiahuiwen Date: Mon, 1 Nov 2021 15:26:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ljsd/jieling/util/http/HttpPool.java | 43 ------------------- 1 file changed, 43 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/http/HttpPool.java b/serverlogic/src/main/java/com/ljsd/jieling/util/http/HttpPool.java index 886858ded..495d0a099 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/http/HttpPool.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/http/HttpPool.java @@ -1,12 +1,8 @@ package com.ljsd.jieling.util.http; -import com.alibaba.fastjson.JSONObject; -import com.google.gson.Gson; -import com.ljsd.jieling.ktbeans.KTSendBody; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; @@ -37,45 +33,6 @@ public class HttpPool { return RequestConfig.custom().setSocketTimeout(5000).setConnectTimeout(50000).setConnectionRequestTimeout(5000).build(); } - public static JSONObject sendPostForm(String url, UrlEncodedFormEntity info) { - HttpPost httpPost = new HttpPost(url); - HttpResponse httpResponse; - int sendTimes = 0; - do { - try { - httpPost.setEntity(info); - httpPost.setConfig(getRequestConfig()); - httpPost.setHeader("Content-Type","application/x-www-form-urlencoded"); - httpResponse = httpclient.execute(httpPost); - - int statusCode = httpResponse.getStatusLine().getStatusCode(); - if (statusCode >= 200 && statusCode < 300) { - LOGGER.debug("Http sendPostForm,第" + (sendTimes + 1) + "次调用成功,返回码为:[" + statusCode + "]"); - HttpEntity responseEntity = httpResponse.getEntity(); - String result = EntityUtils.toString(responseEntity,"UTF-8"); - return JSONObject.parseObject(result); - - } else { - LOGGER.error("Http sendPostForm,第" + (sendTimes + 1) + "次调用出错,返回码为:[" + statusCode + "]"); - if (sendTimes + 1 <= maxSendTimes) { - LOGGER.debug("Http sendPostForm," + (sendIntervalTime / 1000) + "秒后,重新发起请求..."); - try { - Thread.sleep(sendIntervalTime); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } else { - LOGGER.debug("Http sendPostForm,达到重发最大次数,退出程序!"); - } - } - } catch (IOException e) { - LOGGER.error("Http Send error",e); - }finally { - sendTimes ++ ; - } - } while (sendTimes < maxSendTimes); - return null; - } public static String sendPost(String url, String info,String content_type) { HttpPost httpPost = new HttpPost(url);