|
33 | 33 | import org.springframework.beans.BeanUtils;
|
34 | 34 | import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder;
|
35 | 35 | import org.springframework.boot.http.client.ClientHttpRequestFactorySettings;
|
| 36 | +import org.springframework.boot.http.client.ClientHttpRequestFactorySettings.Redirects; |
36 | 37 | import org.springframework.boot.ssl.SslBundle;
|
37 | 38 | import org.springframework.http.client.ClientHttpRequest;
|
38 | 39 | import org.springframework.http.client.ClientHttpRequestFactory;
|
|
64 | 65 | * @author Kevin Strijbos
|
65 | 66 | * @author Ilya Lukyanovich
|
66 | 67 | * @author Scott Frederick
|
| 68 | + * @author Yanming Zhou |
67 | 69 | * @since 1.4.0
|
68 | 70 | */
|
69 | 71 | public class RestTemplateBuilder {
|
@@ -501,6 +503,19 @@ public RestTemplateBuilder readTimeout(Duration readTimeout) {
|
501 | 503 | this.defaultHeaders, this.customizers, this.requestCustomizers);
|
502 | 504 | }
|
503 | 505 |
|
| 506 | + /** |
| 507 | + * Sets the redirect strategy on the underlying {@link ClientHttpRequestFactory}. |
| 508 | + * @param redirects the redirect strategy |
| 509 | + * @return a new builder instance. |
| 510 | + * @since 3.4.1 |
| 511 | + */ |
| 512 | + public RestTemplateBuilder redirects(Redirects redirects) { |
| 513 | + return new RestTemplateBuilder(this.requestFactorySettings.withRedirects(redirects), this.detectRequestFactory, |
| 514 | + this.rootUri, this.messageConverters, this.interceptors, this.requestFactoryBuilder, |
| 515 | + this.uriTemplateHandler, this.errorHandler, this.basicAuthentication, this.defaultHeaders, |
| 516 | + this.customizers, this.requestCustomizers); |
| 517 | + } |
| 518 | + |
504 | 519 | /**
|
505 | 520 | * Sets the SSL bundle on the underlying {@link ClientHttpRequestFactory}.
|
506 | 521 | * @param sslBundle the SSL bundle
|
|
0 commit comments