Skip to content

Commit

Permalink
Fix 307 redirect errors when connecting to multi-broker cluster (apac…
Browse files Browse the repository at this point in the history
…he#503)

Co-authored-by: Apurva Telang <[email protected]>
  • Loading branch information
Apurva007 and Apurva Telang authored Dec 30, 2022
1 parent 3570983 commit d92cfd8
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.client.LaxRedirectStrategy;
import org.apache.http.ssl.SSLContexts;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
Expand Down Expand Up @@ -46,6 +47,12 @@ public class HttpsClientConfiguration {

@Bean
public CloseableHttpClient httpClient() throws Exception {
LaxRedirectStrategy customLaxRedirectStrategy = new LaxRedirectStrategy() {
@Override
protected boolean isRedirectable(final String method) {
return true;
}
};
if (tlsEnabled) {
Resource resource = new FileSystemResource(tlsKeystore);
File trustStoreFile = resource.getFile();
Expand All @@ -68,9 +75,10 @@ public CloseableHttpClient httpClient() throws Exception {
hostnameVerifier);

return HttpClients.custom()
.setRedirectStrategy(customLaxRedirectStrategy)
.setSSLSocketFactory(sslsf)
.build();
}
return HttpClients.custom().build();
return HttpClients.custom().setRedirectStrategy(customLaxRedirectStrategy).build();
}
}

0 comments on commit d92cfd8

Please sign in to comment.