Skip to content

Commit d92cfd8

Browse files
Apurva007Apurva Telang
andauthored
Fix 307 redirect errors when connecting to multi-broker cluster (#503)
Co-authored-by: Apurva Telang <atelang@paypal.com>
1 parent 3570983 commit d92cfd8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/java/org/apache/pulsar/manager/zuul/HttpsClientConfiguration.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
1818
import org.apache.http.impl.client.CloseableHttpClient;
1919
import org.apache.http.impl.client.HttpClients;
20+
import org.apache.http.impl.client.LaxRedirectStrategy;
2021
import org.apache.http.ssl.SSLContexts;
2122
import org.springframework.beans.factory.annotation.Value;
2223
import org.springframework.context.annotation.Bean;
@@ -46,6 +47,12 @@ public class HttpsClientConfiguration {
4647

4748
@Bean
4849
public CloseableHttpClient httpClient() throws Exception {
50+
LaxRedirectStrategy customLaxRedirectStrategy = new LaxRedirectStrategy() {
51+
@Override
52+
protected boolean isRedirectable(final String method) {
53+
return true;
54+
}
55+
};
4956
if (tlsEnabled) {
5057
Resource resource = new FileSystemResource(tlsKeystore);
5158
File trustStoreFile = resource.getFile();
@@ -68,9 +75,10 @@ public CloseableHttpClient httpClient() throws Exception {
6875
hostnameVerifier);
6976

7077
return HttpClients.custom()
78+
.setRedirectStrategy(customLaxRedirectStrategy)
7179
.setSSLSocketFactory(sslsf)
7280
.build();
7381
}
74-
return HttpClients.custom().build();
82+
return HttpClients.custom().setRedirectStrategy(customLaxRedirectStrategy).build();
7583
}
7684
}

0 commit comments

Comments
 (0)