In our application we're using
public class CustomRestTemplateCreator {
public CustomRestTemplate create(String user, String password) {
return new RestTemplateBuilder()
.basicAuthentication(user, password)
.requestFactory(() -> new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory()))
.build(CustomRestTemplate .class);
Which is used by
public CustomClient create(Server server) {
String ipAddress = server.getAddress();
AccessDTO accessDTO = AccessInterceptor.getAcces(ipAddress);
CustomRestTemplate customRestTemplate = customRestTemplateCreator.create(accessDTO.getUsername(), accessDTO.getPassword());
ServerUrl serverUrl = new ServerUrl(HTTP, accessDTO.getAddress(), port);
return new CustomClientImpl(serverUrl, customRestTemplate);
}
And CustomClientImpl have isComponentAvaliable()
method, which is restTemplate.getForObject()
and returns true or false.
Problem is that some servers forcing HTTPS connection, and we're getting following error:
org.springframework.web.client.UnknownContentTypeException: Could not extract response: no suitable HttpMessageConverter found for response type [class com.some.class] and content type [text/html]
When we're trying the same endpoint manually or by postman everything is fine, but Spring look like have problem with redirecting between protocols.
Is there some way to automatically follow that redirection ?