We are looking at upgrading from Jersey 1 / HttpClient 3.1 to Jersey 2 / HttpClient 4.5.12.
We make REST calls to a 3rd party software product uses a unique protocol and port (HTTPS over sec-http on port 8112) instead of a standard https/443. So an example URL would be HTTPS traffic over sec-http://myserver:8112/person/1
Does anyone know how to set up Jersey 2 / HttpClient 4.x to use a custom protocol and custom port?
Before we had the following code for Jersey 1 / HttpClient 3.1:
final Protocol protocol = new Protocol("sec-http",
(ProtocolSocketFactory) new SocketFactory(this.sslContext), 8112);
Protocol.registerProtocol(protocolScheme, protocol);
For the life of me, I can't get this to work in Jersey 2 / HttpClient 4.5.12. The Protocol class is gone.
Here's what I've tried:
LayeredConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(this.sslContext);
Registry<ConnectionSocketFactory> r = RegistryBuilder.<ConnectionSocketFactory>create()
.register("sec-http", sslsf) // how do I specify a custom port?!
.build();
PoolingHttpClientConnectionManager httpClientConnectionManager = new PoolingHttpClientConnectionManager(r);
ClientConfig clientConfig = new ClientConfig();
clientConfig.connectorProvider(new ApacheConnectorProvider());
clientConfig.property(ApacheClientProperties.CONNECTION_MANAGER, httpClientConnectionManager);
clientConfig.property(ApacheClientProperties.DISABLE_COOKIES, Boolean.FALSE);
clientConfig.register(new JacksonFeature());
Client client = ClientBuilder.newBuilder()
.withConfig(clientConfig)
.build();