Skip to content

Commit

Permalink
add method
Browse files Browse the repository at this point in the history
  • Loading branch information
KenelLiu authored and KenelLiu committed Jul 28, 2017
1 parent c4879f2 commit c94b837
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
3 changes: 1 addition & 2 deletions CDOUtil/src/main/java/com/cdo/util/http/HttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ private void setRequestParam() {
entity = new UrlEncodedFormEntity(paramsList,Charset.forName(Constants.Encoding.CHARSET_UTF8));
}
}




/**4.5
*
Expand Down
45 changes: 45 additions & 0 deletions CDOUtil/src/main/java/com/cdo/util/http/HttpUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,22 @@ private static Response post(String url,Map<String, String> params,Map<String, S
return client.execute();
}

/**
*
* @param url
* @param httpMethod
* @param params
* @param header
* @return
* @throws ResponseException
*/
public static Response doMethod(String url,String httpMethod,Map<String, String> params,Map<String, String> header) throws ResponseException{
com.cdo.util.http.HttpClient client=new com.cdo.util.http.HttpClient(url);
client.setHeaders(header);
client.setNameValuePair(params);
client.setMethod(httpMethod);
return client.execute();
}

//-------------------普通获取get --------------------//
/**
Expand Down Expand Up @@ -376,5 +392,34 @@ public static Response postBody(String url,String strContent,Map<String, String>
return null;
}

//-------------------- body-----------------------------//
/**
*
* @param url
* @param strContent
* @return Response responseText 返回文本
* @throws ResponseException
*/
public static Response doMethodBody(String url,String strContent,String httpMehtod) throws ResponseException{
return doMethodBody(url,strContent,httpMehtod,null);
}
/**
*
* @param url
* @param strContent
* @param header
* @return Response responseText 返回文本
* @throws ResponseException
*/
public static Response doMethodBody(String url,String strContent,String httpMehtod,Map<String, String> header) throws ResponseException{

com.cdo.util.http.HttpClient client=new com.cdo.util.http.HttpClient(url);
client.setHeaders(header);
client.setTransMode(com.cdo.util.http.HttpClient.TRANSMODE_BODY);
client.setBody(strContent);
client.setMethod(httpMehtod);
return client.execute();
}


}

0 comments on commit c94b837

Please sign in to comment.