xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 4KB
    文件類型: .java
    金幣: 1
    下載: 1 次
    發(fā)布日期: 2021-06-24
  • 語言: Java
  • 標(biāo)簽: send??put??delete??post??get請求??

資源簡介

是一個Java 發(fā)送http put、delete、 post、 get 請求的工具類。可用在與restful service 進(jìn)行通訊的代碼中。

資源截圖

代碼片段和文件信息

package?com.ganji.as.restful.service.spi.intf;

import?java.io.IOException;
import?java.io.UnsupportedEncodingException;
import?java.util.ArrayList;
import?java.util.List;
import?java.util.Map;

import?org.apache.commons.logging.Log;
import?org.apache.commons.logging.LogFactory;
import?org.apache.http.HttpResponse;
import?org.apache.http.HttpStatus;
import?org.apache.http.client.HttpClient;
import?org.apache.http.client.entity.UrlEncodedFormEntity;
import?org.apache.http.client.methods.HttpDelete;
import?org.apache.http.client.methods.HttpPut;
import?org.apache.http.impl.client.DefaultHttpClient;
import?org.apache.http.message.BasicNameValuePair;
import?org.apache.http.protocol.HTTP;
import?org.apache.http.util.EntityUtils;

import?com.ganji.common.utils.HttpUtil;

/***
?*?
?*?@author?yikangfeng
?*
?*/
class?RestfulRequestHelper?extends?HttpUtil?{
static?private?final?Log?LOG?=?LogFactory
.getLog(RestfulRequestHelper.class);

static?public?String?sendPOST(String?restfulUrl?Map?params)?{
return?doPost(restfulUrl?params);
}

static?public?String?sendDELETE(String?restfulUrl
Map?params)?{
HttpClient?client?=?new?DefaultHttpClient();
HttpDelete?requestDelete?=?new?HttpDelete(restfulUrl);
requestDelete
.setHeader(“Accept“
“application/json?application/xml?text/html?text/*?image/*?*/*“);
String?result?=?““;
try?{
HttpResponse?httpResponse?=?client.execute(requestDelete);
if?(httpResponse?==?null)
return?result;
if?(httpResponse.getStatusLine().getStatusCode()?==?HttpStatus.SC_OK)
result?=?EntityUtils.toString(httpResponse.getEntity());
}?catch?(IOException?ignore)?{
ignore.printStackTrace();
if?(LOG.isErrorEnabled())
LOG.error(ignore);
}?finally?{
if?(client?!=?null)
client

評論

共有 條評論