|
|
@@ -128,8 +128,13 @@ public class HttpUtil {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public static Response sendGetRequest(String url, HashMap<String, String> header, Map<String, String> params, boolean sign, String signKey) throws Exception {
|
|
|
- return sendRequest(RequestMethod.GET, url, header, params, sign, signKey);
|
|
|
- }
|
|
|
+ return sendRequest(RequestMethod.GET, url, header, params, sign, signKey);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static Response sendGetRequest2( String url,Map<String, String> params, boolean sign, String signKey) throws Exception {
|
|
|
+ return sendRequest2(RequestMethod.GET, url, params, sign, signKey);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 发送GET请求
|
|
|
@@ -145,6 +150,8 @@ public class HttpUtil {
|
|
|
return sendRequest(RequestMethod.GET, url, header, params, sign, null);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 发送POST请求
|
|
|
*
|
|
|
@@ -481,6 +488,37 @@ public class HttpUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public static Response sendRequest2(RequestMethod method, String url, Map<String, String> params, boolean sign, String signKey)
|
|
|
+ throws Exception {
|
|
|
+
|
|
|
+ switch (method) {
|
|
|
+ case GET: {
|
|
|
+ HttpRequestBase request = new HttpGet(getRequestUrl(url, params, sign, signKey));
|
|
|
+ return sendHttpUriRequest(request);
|
|
|
+ }
|
|
|
+ case POST: {
|
|
|
+ HttpPost request = new HttpPost(getRequestUrl(url, sign, signKey));
|
|
|
+ return sendHttpEntityEnclosingRequest(request, params);
|
|
|
+ }
|
|
|
+ case PUT: {
|
|
|
+ HttpPut request = new HttpPut(getRequestUrl(url, sign, signKey));
|
|
|
+ return sendHttpEntityEnclosingRequest(request, params);
|
|
|
+ }
|
|
|
+ case DELETE: {
|
|
|
+ HttpDelete request = new HttpDelete(getRequestUrl(url, params, sign, signKey));
|
|
|
+ return sendHttpUriRequest(request);
|
|
|
+ }
|
|
|
+ default: {
|
|
|
+ HttpGet request = new HttpGet(getRequestUrl(url, params, sign, signKey));
|
|
|
+ return sendHttpUriRequest(request);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 发起http请求
|
|
|
*
|