Skip to content

Commit 7c37f4b

Browse files
committed
Follow redirects in JdkClientHttpRequestFactory
Make sure we follow redirects in the default HttpClient created by JdkClientHttpRequestFactory, similar toSimpleClientHttpRequestFactory.
1 parent 6793edc commit 7c37f4b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

spring-web/src/main/java/org/springframework/http/client/JdkClientHttpRequestFactory.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ public class JdkClientHttpRequestFactory implements ClientHttpRequestFactory {
4848

4949
/**
5050
* Create a new instance of the {@code JdkClientHttpRequestFactory}
51-
* with a default {@link HttpClient}.
51+
* with a default {@link HttpClient} that follows redirects.
5252
*/
5353
public JdkClientHttpRequestFactory() {
54-
this(HttpClient.newHttpClient());
54+
this(HttpClient.newBuilder()
55+
.followRedirects(HttpClient.Redirect.NORMAL)
56+
.build());
5557
}
5658

5759
/**

0 commit comments

Comments
 (0)