由于Commons HttpClient项目现已终止。我想将代码迁移到httpcomponent。

时间:2018-08-02 10:26:11

标签: httpclient apache-httpcomponents

如何在CloseableHttpClient对象上设置HostConfiguration。较早时,我曾经使用Commons httpclient

myHttpClient.getHostConfiguration().setHost( host, port, baseHttps )

Apache HttpComponents项目中的等效项是什么?

1 个答案:

答案 0 :(得分:0)

请参考以下代码:

URI uri = new URI(myURIString);

HttpClientContext context = HttpClientContext.create();

HttpRoute route = new HttpRoute(new HttpHost(host,uri.getPort(),uri.getScheme()));