How do I replace Deprecated httpClient.getParams() with RequestConfig?

后端 未结 2 1642
傲寒
傲寒 2020-12-31 03:23

I have inherited the code

import org.apache.http.client.HttpClient;
...
HttpClient httpclient = createHttpClientOrProxy();
...



private HttpClient createH         


        
2条回答
  •  遥遥无期
    2020-12-31 03:43

    This is more of a follow-up to the answer given by @Stephane Lallemagne

    There is a much conciser way of making HttpClient pick up system proxy settings

    CloseableHttpClient client = HttpClients.custom()
            .setRoutePlanner(
                 new SystemDefaultRoutePlanner(ProxySelector.getDefault()))
            .build();
    

    or this if you want an instance of HttpClient fully configured with system defaults

    CloseableHttpClient client = HttpClients.createSystem();
    

提交回复
热议问题