|
@@ -10,6 +10,8 @@ import org.apache.http.entity.StringEntity; |
|
|
import org.apache.http.impl.client.CloseableHttpClient; |
|
|
import org.apache.http.impl.client.CloseableHttpClient; |
|
|
import org.apache.http.impl.client.HttpClients; |
|
|
import org.apache.http.impl.client.HttpClients; |
|
|
import org.apache.http.util.EntityUtils; |
|
|
import org.apache.http.util.EntityUtils; |
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
|
import javax.net.ssl.KeyManagerFactory; |
|
|
import javax.net.ssl.KeyManagerFactory; |
|
|
import javax.net.ssl.SSLContext; |
|
|
import javax.net.ssl.SSLContext; |
|
@@ -25,6 +27,8 @@ import java.util.Map; |
|
|
|
|
|
|
|
|
public class HttpClientUtils { |
|
|
public class HttpClientUtils { |
|
|
|
|
|
|
|
|
|
|
|
private final static Logger logger = LoggerFactory.getLogger(HttpClientUtils.class); |
|
|
|
|
|
|
|
|
public static final String CONTENT_TYPE_XML = "application/xml"; |
|
|
public static final String CONTENT_TYPE_XML = "application/xml"; |
|
|
public static final String DEFAULT_CONTENT_TYPE = "application/json"; |
|
|
public static final String DEFAULT_CONTENT_TYPE = "application/json"; |
|
|
public static final String DEFAULT_CHARSET = "UTF-8"; |
|
|
public static final String DEFAULT_CHARSET = "UTF-8"; |
|
@@ -56,6 +60,10 @@ public class HttpClientUtils { |
|
|
result = EntityUtils.toString(responseEntity, DEFAULT_CHARSET); |
|
|
result = EntityUtils.toString(responseEntity, DEFAULT_CHARSET); |
|
|
} catch (IOException e) { |
|
|
} catch (IOException e) { |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|
|
|
|
logger.error("httpRequest error. url:"+url+",params:"+data+", contentType:"+contentType,e); |
|
|
|
|
|
} |
|
|
|
|
|
if (null != result) { |
|
|
|
|
|
logger.debug("httpRequest debug. url:"+url+",params:"+data+", contentType:"+contentType +". response:"+result); |
|
|
} |
|
|
} |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|