|
|
package com.monitor.other.dns.service.impl;
|
|
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import org.springframework.http.*;
|
|
|
import com.monitor.other.dns.service.IRestTemplateNoEncode;
|
|
|
import org.apache.http.config.Registry;
|
|
|
import org.apache.http.config.RegistryBuilder;
|
...
|
...
|
@@ -14,8 +15,6 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; |
|
|
import org.apache.http.ssl.SSLContextBuilder;
|
|
|
import org.apache.http.ssl.TrustStrategy;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.http.HttpMethod;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.client.RestTemplate;
|
...
|
...
|
@@ -36,6 +35,8 @@ import java.security.cert.CertificateException; |
|
|
import java.security.cert.X509Certificate;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import static java.util.Collections.singletonList;
|
|
|
|
|
|
/**
|
|
|
* Created by yoho on 2016/8/2.
|
|
|
*/
|
...
|
...
|
@@ -151,6 +152,22 @@ public class RestTemplateNoEncodeImpl implements IRestTemplateNoEncode{ |
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String doGet(String uri, String host) {
|
|
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
headers.set("Host", host);
|
|
|
HttpEntity entity = new HttpEntity(headers);
|
|
|
|
|
|
String result = null;
|
|
|
try {
|
|
|
result = restTemplate.exchange(uri,HttpMethod.GET,entity,String.class).getBody();
|
|
|
} catch (Exception e) {
|
|
|
logger.error("doGet failed!", e);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String doGetResponseCode(String uri) {
|
|
|
String result = null;
|
|
|
try {
|
...
|
...
|
|