仅为特定的httpclient注册协议

时间:2019-05-06 08:03:07

标签: java resttemplate apache-commons apache-commons-httpclient sslsocketfactory

早上好,我在代码中引用此网站。 https://hc.apache.org/httpclient-3.x/sslguide.html

我正在使用旧版本的httpClient和apache协议。

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.protocol.Protocol;

我已经注册了协议,以下是我的代码的一部分

// sf is my socketFactory object
Protocol myhttps = new Protocol("https", sf, 443);
Protocol.registerProtocol("https", myhttps);
CommonsClientHttpRequestFactory requestFactory = new CommonsClientHttpRequestFactory(httpclient);
restTemplate = new RestTemplate( requestFactory );

这将导致我的其他httpClient出现问题,因为该协议已在此sf套接字工厂中注册。

我打算仅为此httpClient注册协议,而不要注册所有协议。但是我找不到办法。

有人可以建议吗?

0 个答案:

没有答案