|
|
@@ -69,6 +69,39 @@ public class HttpUtils {
|
|
|
return HttpClients.createDefault();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public static String kuaiShouhttpPostRequest(String url, String body, Map<String, String> headers) {
|
|
|
+ HttpClient httpClient = createSslClientDefault();
|
|
|
+ String strReturn = "";
|
|
|
+ try {
|
|
|
+ HttpPost httppost = new HttpPost(url);
|
|
|
+ RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(120000).setConnectTimeout(120000).build();
|
|
|
+ httppost.setConfig(requestConfig);
|
|
|
+ if (!Check.isNullMap(headers)) {
|
|
|
+ for (String key : headers.keySet()) {
|
|
|
+ httppost.setHeader(key, headers.get(key));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ httppost.setHeader("User-Agent", USER_AGENT);
|
|
|
+ if (!Check.isNull(body)) {
|
|
|
+ httppost.setEntity(new StringEntity(body, Charset.forName("UTF-8")));
|
|
|
+ }
|
|
|
+ HttpEntity respentity;
|
|
|
+ HttpResponse response = httpClient.execute(httppost);
|
|
|
+ int statusCode = response.getStatusLine().getStatusCode();
|
|
|
+ if (statusCode == HttpStatus.SC_OK) {
|
|
|
+ respentity = response.getEntity();
|
|
|
+ strReturn = EntityUtils.toString(respentity);
|
|
|
+ return strReturn;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error(e.getMessage());
|
|
|
+ }
|
|
|
+ return strReturn;
|
|
|
+ }
|
|
|
+
|
|
|
public static String httpPostRequest(String url, Map<String, Object> param, Map<String, String> headers) {
|
|
|
|
|
|
HttpClient httpClient = createSslClientDefault();
|