HttpClient httpClient = new HttpClient(); String proxyHost = "your_proxy_host"; int proxyPort = your_proxy_port; httpClient.getHostConfiguration().setProxy(proxyHost, proxyPort); String proxyUsername = "your_proxy_username"; String proxyPassword = "your_proxy_password"; Credentials credentials = new UsernamePasswordCredentials(proxyUsername, proxyPassword); httpClient.getState().setProxyCredentials(AuthScope.ANY, credentials); String requestUrl = "http://example.com/api/endpoint"; GetMethod method = new GetMethod(requestUrl); httpClient.executeMethod(method); String response = method.getResponseBodyAsString();


上一篇:
下一篇:
切换中文