public static void createHttpClient() {
HttpClientBuilder clientBuilder = HttpClientBuilder.create();
String ip = System.getProperty("com.thesimego.proxy.ip");
String port = System.getProperty("com.thesimego.proxy.port");
String login = System.getProperty("com.thesimego.proxy.login");
String password = System.getProperty("com.thesimego.proxy.password");
if(ip != null && port != null && !ip.trim().isEmpty() && !port.trim().isEmpty()) {
if(login != null && password != null && !login.trim().isEmpty() && !password.trim().isEmpty()) {
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(
new AuthScope(ip, Integer.parseInt(port)),
new UsernamePasswordCredentials(login, password));
clientBuilder.setDefaultCredentialsProvider(credsProvider);
}
clientBuilder.useSystemProperties();
clientBuilder.setProxy(new HttpHost(ip, Integer.parseInt(port)));
clientBuilder.setProxyAuthenticationStrategy(new ProxyAuthenticationStrategy());
}
httpClient = clientBuilder.build();
BasicCookieStore cookieStore = new BasicCookieStore();
httpContext.setAttribute(HttpClientContext.COOKIE_STORE, cookieStore);
}
RequestClient.java 文件源码
java
阅读 19
收藏 0
点赞 0
评论 0
项目:ChatWA-Client
作者:
评论列表
文章目录