1
|
package com.monitor.other.dns.service.impl;
|
1
|
package com.monitor.other.dns.service.impl;
|
2
|
|
2
|
|
3
|
-import org.springframework.http.HttpHeaders;
|
3
|
+import com.google.common.collect.Lists;
|
|
|
4
|
+import org.springframework.http.*;
|
4
|
import com.monitor.other.dns.service.IRestTemplateNoEncode;
|
5
|
import com.monitor.other.dns.service.IRestTemplateNoEncode;
|
5
|
import org.apache.http.config.Registry;
|
6
|
import org.apache.http.config.Registry;
|
6
|
import org.apache.http.config.RegistryBuilder;
|
7
|
import org.apache.http.config.RegistryBuilder;
|
|
@@ -14,8 +15,6 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; |
|
@@ -14,8 +15,6 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; |
14
|
import org.apache.http.ssl.SSLContextBuilder;
|
15
|
import org.apache.http.ssl.SSLContextBuilder;
|
15
|
import org.apache.http.ssl.TrustStrategy;
|
16
|
import org.apache.http.ssl.TrustStrategy;
|
16
|
import org.slf4j.LoggerFactory;
|
17
|
import org.slf4j.LoggerFactory;
|
17
|
-import org.springframework.http.HttpMethod;
|
|
|
18
|
-import org.springframework.http.ResponseEntity;
|
|
|
19
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
18
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
20
|
import org.springframework.stereotype.Service;
|
19
|
import org.springframework.stereotype.Service;
|
21
|
import org.springframework.web.client.RestTemplate;
|
20
|
import org.springframework.web.client.RestTemplate;
|
|
@@ -36,6 +35,8 @@ import java.security.cert.CertificateException; |
|
@@ -36,6 +35,8 @@ import java.security.cert.CertificateException; |
36
|
import java.security.cert.X509Certificate;
|
35
|
import java.security.cert.X509Certificate;
|
37
|
import java.util.Map;
|
36
|
import java.util.Map;
|
38
|
|
37
|
|
|
|
38
|
+import static java.util.Collections.singletonList;
|
|
|
39
|
+
|
39
|
/**
|
40
|
/**
|
40
|
* Created by yoho on 2016/8/2.
|
41
|
* Created by yoho on 2016/8/2.
|
41
|
*/
|
42
|
*/
|
|
@@ -151,6 +152,22 @@ public class RestTemplateNoEncodeImpl implements IRestTemplateNoEncode{ |
|
@@ -151,6 +152,22 @@ public class RestTemplateNoEncodeImpl implements IRestTemplateNoEncode{ |
151
|
}
|
152
|
}
|
152
|
|
153
|
|
153
|
@Override
|
154
|
@Override
|
|
|
155
|
+ public String doGet(String uri, String host) {
|
|
|
156
|
+
|
|
|
157
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
158
|
+ headers.set("Host", host);
|
|
|
159
|
+ HttpEntity entity = new HttpEntity(headers);
|
|
|
160
|
+
|
|
|
161
|
+ String result = null;
|
|
|
162
|
+ try {
|
|
|
163
|
+ result = restTemplate.exchange(uri,HttpMethod.GET,entity,String.class).getBody();
|
|
|
164
|
+ } catch (Exception e) {
|
|
|
165
|
+ logger.error("doGet failed!", e);
|
|
|
166
|
+ }
|
|
|
167
|
+ return result;
|
|
|
168
|
+ }
|
|
|
169
|
+
|
|
|
170
|
+ @Override
|
154
|
public String doGetResponseCode(String uri) {
|
171
|
public String doGetResponseCode(String uri) {
|
155
|
String result = null;
|
172
|
String result = null;
|
156
|
try {
|
173
|
try {
|