本文整理汇总了Java中org.apache.http.impl.client.WinHttpClients.custom方法的典型用法代码示例。如果您正苦于以下问题:Java WinHttpClients.custom方法的具体用法?Java WinHttpClients.custom怎么用?Java WinHttpClients.custom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.http.impl.client.WinHttpClients
的用法示例。
在下文中一共展示了WinHttpClients.custom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHttpClient
import org.apache.http.impl.client.WinHttpClients; //导入方法依赖的package包/类
private HttpClient createHttpClient(Authentication auth, String verify, HttpHost target, Boolean postRedirects,
String password, TrustStrategy keystoreTrustStrategy, HostnameVerifier keystoreHostnameVerifier,
Proxy proxy) {
Certificate certificate = new Certificate();
Auth authHelper = new Auth();
HttpClientBuilder httpClientBuilder = WinHttpClients.custom();
Builder requestConfig = RequestConfig.custom();
requestConfig.setCookieSpec(CookieSpecs.DEFAULT);
logger.debug("Verify value: " + verify);
logger.debug((new File(verify).getAbsolutePath()));
if (new File(verify).exists()) {
logger.debug("Loading custom keystore");
httpClientBuilder.setSSLSocketFactory(
certificate.allowAllCertificates(certificate.createCustomKeyStore(verify.toString(), password),
password, keystoreTrustStrategy, keystoreHostnameVerifier));
} else if (!Boolean.parseBoolean(verify.toString())) {
logger.debug("Allowing all certificates");
httpClientBuilder.setSSLSocketFactory(certificate.allowAllCertificates(null));
}
if (auth.isAuthenticable()) {
httpClientBuilder.setDefaultCredentialsProvider(authHelper.getCredentialsProvider(auth, target));
}
if (proxy != null && proxy.isInUse()) {
logger.debug("Enabling proxy");
if (proxy.isAuthenticable()) {
logger.debug("Setting proxy credentials");
httpClientBuilder.setDefaultCredentialsProvider(
authHelper.getCredentialsProvider(proxy.getAuth(), proxy.getHttpHost()));
}
requestConfig.setProxy(proxy.getHttpHost());
}
if (postRedirects) {
httpClientBuilder.setRedirectStrategy(new CustomRedirectStrategy());
}
httpClientBuilder.setDefaultRequestConfig(requestConfig.build());
return httpClientBuilder.build();
}
示例2: createHttpClient
import org.apache.http.impl.client.WinHttpClients; //导入方法依赖的package包/类
private CloseableHttpClient createHttpClient(ServerInfo serverInfo)
{
HttpClientBuilder builder = (useBuiltinWindowsAuthentication(serverInfo)) ? WinHttpClients.custom() : HttpClients.custom();
HttpClientConnectionManager connMgr = createConnectionManagerIfNecessary();
if (connMgr != null)
{
builder.setConnectionManager(connMgr);
}
builder.setUserAgent(userAgent);
builder.useSystemProperties();
return builder.build();
}