当前位置: 首页>>代码示例>>Java>>正文


Java WinHttpClients.custom方法代码示例

本文整理汇总了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();
}
 
开发者ID:Hi-Fi,项目名称:httpclient,代码行数:44,代码来源:RestClient.java

示例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();
}
 
开发者ID:Esri,项目名称:geoevent-datastore-proxy,代码行数:15,代码来源:GeoEventDataStoreProxy.java


注:本文中的org.apache.http.impl.client.WinHttpClients.custom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。