diff --git a/main/src/main/java/com/sedmelluq/discord/lavaplayer/tools/http/ExtendedHttpClientBuilder.java b/main/src/main/java/com/sedmelluq/discord/lavaplayer/tools/http/ExtendedHttpClientBuilder.java index 50c2c800f..f4cf24556 100644 --- a/main/src/main/java/com/sedmelluq/discord/lavaplayer/tools/http/ExtendedHttpClientBuilder.java +++ b/main/src/main/java/com/sedmelluq/discord/lavaplayer/tools/http/ExtendedHttpClientBuilder.java @@ -47,6 +47,8 @@ public class ExtendedHttpClientBuilder extends HttpClientBuilder { private SSLContext sslContextOverride; private String[] sslSupportedProtocols; + private PlainConnectionSocketFactory plainSocketFactory; + private SSLConnectionSocketFactory sslSocketFactory; private ConnectionManagerFactory connectionManagerFactory = ExtendedHttpClientBuilder::createDefaultConnectionManager; @Override @@ -70,6 +72,14 @@ public void setSslSupportedProtocols(String[] protocols) { this.sslSupportedProtocols = protocols; } + public void setPlainConnectionSocketFactory(PlainConnectionSocketFactory plainSocketFactory) { + this.plainSocketFactory = plainSocketFactory; + } + + public void setSslConnectionSocketFactory(SSLConnectionSocketFactory sslSocketFactory) { + this.sslSocketFactory = sslSocketFactory; + } + public void setConnectionManagerFactory(ConnectionManagerFactory factory) { this.connectionManagerFactory = factory; } @@ -88,12 +98,12 @@ private HttpClientConnectionManager createConnectionManager() { private Registry createConnectionSocketFactory() { HostnameVerifier hostnameVerifier = new DefaultHostnameVerifier(PublicSuffixMatcherLoader.getDefault()); - ConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(sslContextOverride != null ? + ConnectionSocketFactory defaultSslSocketFactory = new SSLConnectionSocketFactory(sslContextOverride != null ? sslContextOverride : defaultSslContext, sslSupportedProtocols, null, hostnameVerifier); return RegistryBuilder.create() - .register("http", PlainConnectionSocketFactory.getSocketFactory()) - .register("https", sslSocketFactory) + .register("http", plainSocketFactory != null ? plainSocketFactory : PlainConnectionSocketFactory.getSocketFactory()) + .register("https", sslSocketFactory != null ? sslSocketFactory : defaultSslSocketFactory) .build(); }