use of org.jboss.resteasy.client.jaxrs.ClientHttpEngineBuilder43 in project robozonky by RoboZonky.
the class ProxyFactory method newResteasyClient.
public static ResteasyClient newResteasyClient() {
final ResteasyClientBuilder builder = new ResteasyClientBuilder().readTimeout(Settings.INSTANCE.getSocketTimeout().get(ChronoUnit.SECONDS), TimeUnit.SECONDS).connectTimeout(Settings.INSTANCE.getConnectionTimeout().get(ChronoUnit.SECONDS), TimeUnit.SECONDS);
/*
* In order to enable redirects, we need to configure the HTTP Client to support that. Unfortunately, if we then
* provide such client to the RESTEasy client builder, it will take the client as is and don't do other things
* that it would have otherwise done to a client that it itself created. Therefore, we do these things
* ourselves, represented by calling the HTTP engine builder.
*/
final ApacheHttpClient43Engine engine = (ApacheHttpClient43Engine) new ClientHttpEngineBuilder43().resteasyClientBuilder(builder).build();
engine.setFollowRedirects(true);
/*
* Supply the provider factory singleton, as otherwise RESTEasy would create a new instance every time.
*/
return new ResteasyClientBuilder().providerFactory(ResteasyProviderFactory.getInstance()).httpEngine(engine).build();
}
Aggregations