Browse Source

HttpClientConnection: Register connection socket factory for http

It is necessary to register a socket connection factory to prevent the
"http protocol is not supported" error when connecting over a proxy.

Change-Id: Iedf554acef841f52c1f2e3401ef0a0583ac5253b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-4.6
Matthias Sohn 8 years ago
parent
commit
b8e3e194e3
  1. 5
      org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java

5
org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java

@ -89,6 +89,7 @@ import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.config.Registry; import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder; import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory; 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.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.X509HostnameVerifier; import org.apache.http.conn.ssl.X509HostnameVerifier;
import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClientBuilder;
@ -157,7 +158,9 @@ public class HttpClientConnection implements HttpConnection {
clientBuilder.setSSLSocketFactory(sslConnectionFactory); clientBuilder.setSSLSocketFactory(sslConnectionFactory);
Registry<ConnectionSocketFactory> registry = RegistryBuilder Registry<ConnectionSocketFactory> registry = RegistryBuilder
.<ConnectionSocketFactory> create() .<ConnectionSocketFactory> create()
.register("https", sslConnectionFactory).build(); .register("https", sslConnectionFactory)
.register("http", PlainConnectionSocketFactory.INSTANCE)
.build();
clientBuilder.setConnectionManager( clientBuilder.setConnectionManager(
new BasicHttpClientConnectionManager(registry)); new BasicHttpClientConnectionManager(registry));
} }

Loading…
Cancel
Save