|
@@ -520,7 +520,7 @@ public class HttpUtils {
|
|
String strReturn = "";
|
|
String strReturn = "";
|
|
try {
|
|
try {
|
|
String uri = url + "?" + mapParamsSortToStringBySeperator(params, "&");
|
|
String uri = url + "?" + mapParamsSortToStringBySeperator(params, "&");
|
|
- System.err.println("调用客户url:" + uri);
|
|
|
|
|
|
+ System.err.println("调用客户url:" + uri);
|
|
HttpGet httpGet = new HttpGet(uri);
|
|
HttpGet httpGet = new HttpGet(uri);
|
|
if (headers != null) {
|
|
if (headers != null) {
|
|
Iterator<String> keyIter = headers.keySet().iterator();
|
|
Iterator<String> keyIter = headers.keySet().iterator();
|
|
@@ -665,15 +665,15 @@ public class HttpUtils {
|
|
HttpClient httpclient = getHttpclient();
|
|
HttpClient httpclient = getHttpclient();
|
|
String strReturn = "";
|
|
String strReturn = "";
|
|
try {
|
|
try {
|
|
-
|
|
|
|
-
|
|
|
|
StringBuilder postBody = new StringBuilder();
|
|
StringBuilder postBody = new StringBuilder();
|
|
- for (Map.Entry<String, Object> entry : params.entrySet()) {
|
|
|
|
- if (entry.getValue() == null) {
|
|
|
|
- continue;
|
|
|
|
|
|
+ if (!Check.isNull(params)) {
|
|
|
|
+ for (Map.Entry<String, Object> entry : params.entrySet()) {
|
|
|
|
+ if (entry.getValue() == null) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ postBody.append(entry.getKey()).append("=").append(URLEncoder.encode(entry.getValue().toString(),
|
|
|
|
+ "utf-8")).append("&");
|
|
}
|
|
}
|
|
- postBody.append(entry.getKey()).append("=").append(URLEncoder.encode(entry.getValue().toString(),
|
|
|
|
- "utf-8")).append("&");
|
|
|
|
}
|
|
}
|
|
if (!params.isEmpty()) {
|
|
if (!params.isEmpty()) {
|
|
postBody.deleteCharAt(postBody.length() - 1);
|
|
postBody.deleteCharAt(postBody.length() - 1);
|
|
@@ -699,4 +699,33 @@ public class HttpUtils {
|
|
}
|
|
}
|
|
return strReturn;
|
|
return strReturn;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public static String KuaiShouttpGetRequestNew(String url, Map<String, String> headers) throws Exception {
|
|
|
|
+ HttpClient httpclient = getHttpclient();
|
|
|
|
+ String strReturn = "";
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ HttpGet httpget = new HttpGet(url );
|
|
|
|
+ log.info("调用媒体链接地址为:{}",url);
|
|
|
|
+ if (headers != null) {
|
|
|
|
+ Iterator<String> keyIter = headers.keySet().iterator();
|
|
|
|
+ while (keyIter.hasNext()) {
|
|
|
|
+ String curKey = keyIter.next();
|
|
|
|
+ if (curKey != null && headers.get(curKey) != null) {
|
|
|
|
+ httpget.addHeader(curKey, headers.get(curKey));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ HttpEntity respentity;
|
|
|
|
+ HttpResponse response = httpclient.execute(httpget);
|
|
|
|
+ respentity = response.getEntity();
|
|
|
|
+ strReturn = EntityUtils.toString(respentity);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return strReturn;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|