删除无用方法

back_recharge
jiahuiwen 2021-11-01 15:26:43 +08:00
parent 51e47e6588
commit b8e9545c55
1 changed files with 0 additions and 43 deletions

View File

@ -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);