From 2ac61c5972d30eb3840ca6d4066f14f87e5adb00 Mon Sep 17 00:00:00 2001 From: Andrew Hulbert Date: Mon, 8 Jun 2015 15:29:14 -0400 Subject: [PATCH] Adding a plain socket factory for use with regular proxies --- .../java/org/apache/nifi/processors/standard/GetHTTP.java | 8 +++++++- .../org/apache/nifi/processors/standard/PostHTTP.java | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/GetHTTP.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/GetHTTP.java index 6e9acdda2e..1ecd1701b6 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/GetHTTP.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/GetHTTP.java @@ -62,6 +62,7 @@ import org.apache.http.config.Registry; import org.apache.http.config.RegistryBuilder; import org.apache.http.conn.HttpClientConnectionManager; import org.apache.http.conn.socket.ConnectionSocketFactory; +import org.apache.http.conn.socket.PlainConnectionSocketFactory; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.conn.ssl.SSLContexts; import org.apache.http.conn.ssl.TrustSelfSignedStrategy; @@ -358,7 +359,12 @@ public class GetHTTP extends AbstractSessionFactoryProcessor { final SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, new String[]{"TLSv1"}, null, SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER); - final Registry socketFactoryRegistry = RegistryBuilder.create().register("https", sslsf).build(); + // Also include a plain socket factory for regular http connections (especially proxies) + final Registry socketFactoryRegistry = + RegistryBuilder.create() + .register("https", sslsf) + .register("http", PlainConnectionSocketFactory.getSocketFactory()) + .build(); conMan = new BasicHttpClientConnectionManager(socketFactoryRegistry); } diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java index 98056cb83b..1dc7aba38d 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java @@ -64,6 +64,7 @@ import org.apache.http.config.RegistryBuilder; import org.apache.http.conn.HttpClientConnectionManager; import org.apache.http.conn.ManagedHttpClientConnection; import org.apache.http.conn.socket.ConnectionSocketFactory; +import org.apache.http.conn.socket.PlainConnectionSocketFactory; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.conn.ssl.SSLContextBuilder; import org.apache.http.conn.ssl.SSLContexts; @@ -362,7 +363,12 @@ public class PostHTTP extends AbstractProcessor { final SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, new String[]{"TLSv1"}, null, SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER); - final Registry socketFactoryRegistry = RegistryBuilder.create().register("https", sslsf).build(); + // Also use a plain socket factory for regular http connections (especially proxies) + final Registry socketFactoryRegistry = + RegistryBuilder.create() + .register("https", sslsf) + .register("http", PlainConnectionSocketFactory.getSocketFactory()) + .build(); conMan = new PoolingHttpClientConnectionManager(socketFactoryRegistry); }