下面列出了org.apache.http.client.methods.HttpDelete#abort() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 封装HTTP DELETE方法
*
* @param
* @return
*/
public static String delete(String url) throws ClientProtocolException, IOException {
HttpClient httpClient = new DefaultHttpClient();
HttpDelete httpDelete = new HttpDelete();
httpDelete.setURI(URI.create(url));
HttpResponse response = httpClient.execute(httpDelete);
String httpEntityContent = getHttpEntityContent(response);
httpDelete.abort();
return httpEntityContent;
}
/**
* 封装HTTP DELETE方法
*
* @param
* @param
* @return
*/
public static String delete(String url, Map<String, String> paramMap)
throws ClientProtocolException, IOException {
HttpClient httpClient = new DefaultHttpClient();
HttpDelete httpDelete = new HttpDelete();
List<NameValuePair> formparams = setHttpParams(paramMap);
String param = URLEncodedUtils.format(formparams, "UTF-8");
httpDelete.setURI(URI.create(url + "?" + param));
HttpResponse response = httpClient.execute(httpDelete);
String httpEntityContent = getHttpEntityContent(response);
httpDelete.abort();
return httpEntityContent;
}
/**
* 封装HTTP DELETE方法
*
* @param
* @return
* @throws ClientProtocolException
* @throws IOException
*/
public static String delete(String url) throws ClientProtocolException, IOException {
HttpClient httpClient = new DefaultHttpClient();
HttpDelete httpDelete = new HttpDelete();
httpDelete.setURI(URI.create(url));
HttpResponse response = httpClient.execute(httpDelete);
String httpEntityContent = getHttpEntityContent(response);
httpDelete.abort();
return httpEntityContent;
}
/**
* 封装HTTP DELETE方法
*
* @param
* @param
* @return
* @throws ClientProtocolException
* @throws IOException
*/
public static String delete(String url, Map<String, String> paramMap) throws ClientProtocolException, IOException {
HttpClient httpClient = new DefaultHttpClient();
HttpDelete httpDelete = new HttpDelete();
List<NameValuePair> formparams = setHttpParams(paramMap);
String param = URLEncodedUtils.format(formparams, "UTF-8");
httpDelete.setURI(URI.create(url + "?" + param));
HttpResponse response = httpClient.execute(httpDelete);
String httpEntityContent = getHttpEntityContent(response);
httpDelete.abort();
return httpEntityContent;
}