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 {
14
14
private final RestTemplate restTemplate ;
15
15
16
16
private RestTemplateContext (){
17
- this .restTemplate = restTemplate (new HttpComponentsClientHttpRequestFactory (
18
- TrustAnyHttpClientFactory .createTrustAnyHttpClient ()));
17
+ HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory (
18
+ TrustAnyHttpClientFactory .createTrustAnyHttpClient ());
19
+ this .restTemplate = restTemplate (requestFactory );
19
20
}
20
21
21
22
public static RestTemplateContext getInstance () {
Original file line number Diff line number Diff line change 3
3
4
4
import lombok .SneakyThrows ;
5
5
import org .apache .http .client .HttpClient ;
6
+ import org .apache .http .client .config .RequestConfig ;
6
7
import org .apache .http .conn .ssl .NoopHostnameVerifier ;
7
8
import org .apache .http .conn .ssl .SSLConnectionSocketFactory ;
8
9
import org .apache .http .impl .client .HttpClients ;
@@ -39,7 +40,13 @@ public static HttpClient createTrustAnyHttpClient() {
39
40
TrustAnyTrustManager trustAnyTrustManager = new TrustAnyTrustManager ();
40
41
sslContext .init (null , new TrustManager [] {trustAnyTrustManager }, null );
41
42
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory (sslContext , NoopHostnameVerifier .INSTANCE );
43
+
44
+ RequestConfig requestConfig = RequestConfig .custom ()
45
+ .setCircularRedirectsAllowed (true )
46
+ .build ();
47
+
42
48
return HttpClients .custom ()
49
+ .setDefaultRequestConfig (requestConfig )
43
50
.setSSLSocketFactory (sslConnectionSocketFactory )
44
51
.build ();
45
52
}
You can’t perform that action at this time.
0 commit comments