Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,8 @@ public class RestClientBuilderImpl implements RestClientBuilder {
public static final MethodInjectionFilter METHOD_INJECTION_FILTER = new MethodInjectionFilter();
public static final ClientHeadersRequestFilter HEADERS_REQUEST_FILTER = new ClientHeadersRequestFilter();

static boolean SSL_ENABLED = true;
static ResteasyProviderFactory PROVIDER_FACTORY;

public static void setSslEnabled(boolean enabled) {
SSL_ENABLED = enabled;
}

public static void setProviderFactory(ResteasyProviderFactory providerFactory) {
PROVIDER_FACTORY = providerFactory;
}
Expand Down Expand Up @@ -260,13 +255,12 @@ public <T> T build(Class<T> aClass) throws IllegalStateException, RestClientDefi
resteasyClientBuilder.connectTimeout(connectTimeout, connectTimeoutUnit);
}

if (!SSL_ENABLED) {
if (useURLConnection()) {
resteasyClientBuilder.httpEngine(new URLConnectionClientEngineBuilder().resteasyClientBuilder(resteasyClientBuilder).build());
resteasyClientBuilder.sslContext(null);
resteasyClientBuilder.trustStore(null);
resteasyClientBuilder.keyStore(null, "");
}

client = resteasyClientBuilder
.build();
client.register(AsyncInterceptorRxInvokerProvider.class);
Expand All @@ -287,6 +281,19 @@ public <T> T build(Class<T> aClass) throws IllegalStateException, RestClientDefi
return proxy;
}

/**
* Determines whether or not to default to using the URLConnection instead of the Apache HTTP Client.
* If the {@code org.jboss.resteasy.microprofile.defaultToURLConnectionHttpClient} system property is {@code true},
* then this method returns {@code true}. In all other cases it returns {@code false}
*/
private boolean useURLConnection() {
if (useURLConnection == null) {
String defaultToURLConnection = System.getProperty("org.jboss.resteasy.microprofile.defaultToURLConnectionHttpClient", "false");
useURLConnection = defaultToURLConnection.toLowerCase().equals("true");
}
return useURLConnection;
}

private Optional<InetSocketAddress> selectHttpProxy() {
return ProxySelector.getDefault().select(baseURI).stream()
.filter(proxy -> proxy.type() == java.net.Proxy.Type.HTTP)
Expand Down Expand Up @@ -622,6 +629,7 @@ ResteasyClientBuilder getBuilderDelegate() {
private KeyStore keyStore;
private String keystorePassword;
private HostnameVerifier hostnameVerifier;
private Boolean useURLConnection;


private Set<Object> localProviderInstances = new HashSet<>();
Expand Down

This file was deleted.