File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
springboot-starter/src/main/java/com/codingapi/springboot/framework Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,9 @@ public class RestTemplateContext {
1414 private final RestTemplate restTemplate ;
1515
1616 private RestTemplateContext (){
17- this .restTemplate = restTemplate (new HttpComponentsClientHttpRequestFactory (
18- TrustAnyHttpClientFactory .createTrustAnyHttpClient ()));
17+ HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory (
18+ TrustAnyHttpClientFactory .createTrustAnyHttpClient ());
19+ this .restTemplate = restTemplate (requestFactory );
1920 }
2021
2122 public static RestTemplateContext getInstance () {
Original file line number Diff line number Diff line change 33
44import lombok .SneakyThrows ;
55import org .apache .http .client .HttpClient ;
6+ import org .apache .http .client .config .RequestConfig ;
67import org .apache .http .conn .ssl .NoopHostnameVerifier ;
78import org .apache .http .conn .ssl .SSLConnectionSocketFactory ;
89import org .apache .http .impl .client .HttpClients ;
@@ -39,7 +40,13 @@ public static HttpClient createTrustAnyHttpClient() {
3940 TrustAnyTrustManager trustAnyTrustManager = new TrustAnyTrustManager ();
4041 sslContext .init (null , new TrustManager [] {trustAnyTrustManager }, null );
4142 SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory (sslContext , NoopHostnameVerifier .INSTANCE );
43+
44+ RequestConfig requestConfig = RequestConfig .custom ()
45+ .setCircularRedirectsAllowed (true )
46+ .build ();
47+
4248 return HttpClients .custom ()
49+ .setDefaultRequestConfig (requestConfig )
4350 .setSSLSocketFactory (sslConnectionSocketFactory )
4451 .build ();
4552 }
You can’t perform that action at this time.
0 commit comments