Java 使用 HTTP 客户端 4.5 客户端获取语句

Java using HTTP client 4.5 client get statements

我正在尝试将代码从 Apache HTTP 客户端 3.1 更新到 4.5,我有几种方法,例如 client.getHostConfigurationclient.getStateclient.getHttpConnectionManager。所有这些在较新版本的 httpclient 中都不起作用,所以我想知道如何重写这些。我在 HTTP 客户端文档中看到的只是 getParams。但我不知道如何从中获取所有其他信息。

如果有人想要这些正在使用的上下文

if(getProxy() != null) {
        client.getHostConfiguration().setProxy(getProxy().getHost(),getProxy().getPort());
        if (HttpProxyCredentials.isProxySet()) {
            AuthScope authScope = new AuthScope(getProxy().getHost(), getProxy().getPort()); 
            client.getState().setProxyCredentials(authScope, new NTCredentials(HttpProxyCredentials.getUserName(),
                    HttpProxyCredentials.getPassword(),
                    "",HttpProxyCredentials.getDomain())); 

这是构建方法的现代代理示例:

RequestConfig defaultRequestConfig = RequestConfig.custom()
                .setCookieSpec(CookieSpecs.BEST_MATCH)
                .setExpectContinueEnabled(true)
                .setStaleConnectionCheckEnabled(true).setSocketTimeout(timeout)
                .build();

        if (proxyHost != null) {
            defaultRequestConfig = RequestConfig.copy(defaultRequestConfig)
                    .setProxy(new HttpHost(proxyHost, proxyPort)).build();
        }

        method.setConfig(defaultRequestConfig);