本文整理汇总了Java中org.apache.http.impl.conn.DefaultSchemePortResolver类的典型用法代码示例。如果您正苦于以下问题:Java DefaultSchemePortResolver类的具体用法?Java DefaultSchemePortResolver怎么用?Java DefaultSchemePortResolver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultSchemePortResolver类属于org.apache.http.impl.conn包,在下文中一共展示了DefaultSchemePortResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import org.apache.http.impl.conn.DefaultSchemePortResolver; //导入依赖的package包/类
@Override
public HttpClientConnectionManager create(final HttpClientSettings settings) {
ConnectionSocketFactory sslsf = getPreferredSocketFactory(settings);
final PoolingHttpClientConnectionManager cm = new
PoolingHttpClientConnectionManager(
createSocketFactoryRegistry(sslsf),
null,
DefaultSchemePortResolver.INSTANCE,
new DelegatingDnsResolver(settings.getDnsResolver()),
settings.getConnectionPoolTTL(),
TimeUnit.MILLISECONDS);
cm.setValidateAfterInactivity(settings.getValidateAfterInactivityMillis());
cm.setDefaultMaxPerRoute(settings.getMaxConnections());
cm.setMaxTotal(settings.getMaxConnections());
cm.setDefaultSocketConfig(buildSocketConfig(settings));
cm.setDefaultConnectionConfig(buildConnectionConfig(settings));
return cm;
}
示例2: create
import org.apache.http.impl.conn.DefaultSchemePortResolver; //导入依赖的package包/类
public HttpClientConnectionManager create(ApacheSdkHttpClientFactory configuration,
AttributeMap standardOptions) {
ConnectionSocketFactory sslsf = getPreferredSocketFactory(standardOptions);
final PoolingHttpClientConnectionManager cm = new
PoolingHttpClientConnectionManager(
createSocketFactoryRegistry(sslsf),
null,
DefaultSchemePortResolver.INSTANCE,
null,
configuration.connectionTimeToLive().orElse(Defaults.CONNECTION_POOL_TTL).toMillis(),
TimeUnit.MILLISECONDS);
cm.setDefaultMaxPerRoute(standardOptions.get(SdkHttpConfigurationOption.MAX_CONNECTIONS));
cm.setMaxTotal(standardOptions.get(SdkHttpConfigurationOption.MAX_CONNECTIONS));
cm.setDefaultSocketConfig(buildSocketConfig(standardOptions));
return cm;
}
示例3: build
import org.apache.http.impl.conn.DefaultSchemePortResolver; //导入依赖的package包/类
@Override
public HttpClientBuilder build(final TranscriptListener listener, final LoginCallback prompt) {
final HttpClientBuilder builder = super.build(listener, prompt);
// Add filter to inject custom headers to authenticate with proxy
builder.setRequestExecutor(
new CustomHeaderHttpRequestExecutor(headers)
);
// Set proxy router planer
builder.setRoutePlanner(new DefaultProxyRoutePlanner(
new HttpHost(proxy.getHostname(), proxy.getPort(), proxy.getProtocol().getScheme().name()),
new DefaultSchemePortResolver()));
return builder;
}
示例4: usingHttpComponents
import org.apache.http.impl.conn.DefaultSchemePortResolver; //导入依赖的package包/类
static ClientHttpRequestFactory usingHttpComponents(ClientOptions options,
SslConfiguration sslConfiguration) throws GeneralSecurityException,
IOException {
HttpClientBuilder httpClientBuilder = HttpClients.custom();
httpClientBuilder.setRoutePlanner(new SystemDefaultRoutePlanner(
DefaultSchemePortResolver.INSTANCE, ProxySelector.getDefault()));
if (hasSslConfiguration(sslConfiguration)) {
SSLContext sslContext = getSSLContext(sslConfiguration);
SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(
sslContext);
httpClientBuilder.setSSLSocketFactory(sslSocketFactory);
httpClientBuilder.setSSLContext(sslContext);
}
RequestConfig requestConfig = RequestConfig
.custom()
//
.setConnectTimeout(
Math.toIntExact(options.getConnectionTimeout().toMillis())) //
.setSocketTimeout(
Math.toIntExact(options.getReadTimeout().toMillis())) //
.setAuthenticationEnabled(true) //
.build();
httpClientBuilder.setDefaultRequestConfig(requestConfig);
// Support redirects
httpClientBuilder.setRedirectStrategy(new LaxRedirectStrategy());
return new HttpComponentsClientHttpRequestFactory(httpClientBuilder.build());
}
示例5: BasicAuthCache
import org.apache.http.impl.conn.DefaultSchemePortResolver; //导入依赖的package包/类
/**
* Default constructor.
*
* @since 4.3
*/
public BasicAuthCache(final SchemePortResolver schemePortResolver) {
super();
this.map = new HashMap<HttpHost, AuthScheme>();
this.schemePortResolver = schemePortResolver != null ? schemePortResolver :
DefaultSchemePortResolver.INSTANCE;
}
示例6: setupProxying
import org.apache.http.impl.conn.DefaultSchemePortResolver; //导入依赖的package包/类
@BeforeClass
public static void setupProxying() {
DnsResolver dnsResolver = prepareProxiedDnsResolver();
DefaultSchemePortResolver schemePortResolver = prepareSchemePortResolver();
BasicHttpClientConnectionManager connManager = prepareConnectionManager(dnsResolver, schemePortResolver);
HttpClient httpClient = prepareHttpClient(connManager);
originalHttpClient = (HttpClient) Options.getOption(Option.HTTPCLIENT);
Unirest.setHttpClient(httpClient);
}
示例7: prepareSchemePortResolver
import org.apache.http.impl.conn.DefaultSchemePortResolver; //导入依赖的package包/类
private static DefaultSchemePortResolver prepareSchemePortResolver() {
return new DefaultSchemePortResolver() {
@Override
public int resolve(HttpHost host) throws UnsupportedSchemeException {
if (host.getHostName().equalsIgnoreCase("sushi-shop.test")) {
return 9876;
} else {
return super.resolve(host);
}
}
};
}
示例8: prepareConnectionManager
import org.apache.http.impl.conn.DefaultSchemePortResolver; //导入依赖的package包/类
private static BasicHttpClientConnectionManager prepareConnectionManager(DnsResolver dnsResolver, DefaultSchemePortResolver schemePortResolver) {
return new BasicHttpClientConnectionManager(
RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.getSocketFactory())
.register("https", SSLConnectionSocketFactory.getSocketFactory())
.build(),
null,
schemePortResolver,
dnsResolver
);
}
示例9: BasicAuthCache
import org.apache.http.impl.conn.DefaultSchemePortResolver; //导入依赖的package包/类
/**
* Default constructor.
*
* @since 4.3
*/
public BasicAuthCache(final SchemePortResolver schemePortResolver) {
super();
this.map = new ConcurrentHashMap<HttpHost, byte[]>();
this.schemePortResolver = schemePortResolver != null ? schemePortResolver :
DefaultSchemePortResolver.INSTANCE;
}
示例10: NexusHttpRoutePlanner
import org.apache.http.impl.conn.DefaultSchemePortResolver; //导入依赖的package包/类
/**
* @since 2.5
*/
public NexusHttpRoutePlanner(final Map<String, HttpHost> proxies,
@Nullable final Pattern nonProxyHostsPattern)
{
super(DefaultSchemePortResolver.INSTANCE);
this.proxies = checkNotNull(proxies);
this.nonProxyHostPattern = nonProxyHostsPattern;
}
示例11: getHttpClientWithSSL
import org.apache.http.impl.conn.DefaultSchemePortResolver; //导入依赖的package包/类
public static HttpClient getHttpClientWithSSL(File keyStoreFile, String keyStorePassword, File trustStoreFile, String trustStorePassword) {
try {
SSLContextBuilder sslContextBuilder = SSLContexts.custom()
.useProtocol("TLS")
.loadTrustMaterial(trustStoreFile, trustStorePassword.toCharArray());
if (keyStoreFile != null) {
sslContextBuilder.loadKeyMaterial(keyStoreFile, keyStorePassword.toCharArray(), keyStorePassword.toCharArray());
}
SSLContext sslContext = sslContextBuilder.build();
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.getSocketFactory())
.register("https", socketFactory)
.build();
return HttpClientBuilder.create()
.setSSLSocketFactory(socketFactory)
//.setHostnameVerifier(SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER)
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
.setConnectionManager(new PoolingHttpClientConnectionManager(registry))
.setSchemePortResolver(new DefaultSchemePortResolver())
.build();
} catch (Exception e) {
LOGGER.error("Creating HttpClient with customized SSL failed. We are returning the default one instead.", e);
return HttpClients.createDefault();
}
}
示例12: usingHttpComponents
import org.apache.http.impl.conn.DefaultSchemePortResolver; //导入依赖的package包/类
static ClientHttpRequestFactory usingHttpComponents(ClientOptions options,
SslConfiguration sslConfiguration) throws GeneralSecurityException,
IOException {
HttpClientBuilder httpClientBuilder = HttpClients.custom();
httpClientBuilder.setRoutePlanner(new SystemDefaultRoutePlanner(
DefaultSchemePortResolver.INSTANCE, ProxySelector.getDefault()));
if (hasSslConfiguration(sslConfiguration)) {
SSLContext sslContext = getSSLContext(sslConfiguration);
SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(
sslContext);
httpClientBuilder.setSSLSocketFactory(sslSocketFactory);
httpClientBuilder.setSslcontext(sslContext);
}
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(options.getConnectionTimeout())
.setSocketTimeout(options.getReadTimeout())
.setAuthenticationEnabled(true)
.build();
httpClientBuilder.setDefaultRequestConfig(requestConfig);
// Support redirects
httpClientBuilder.setRedirectStrategy(new LaxRedirectStrategy());
// Fix weird problem `ProtocolException: Content-Length header already present` from `org.apache.http.protocol.RequestContent`
httpClientBuilder.addInterceptorFirst(new HttpRequestInterceptor() {
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
if (request instanceof HttpEntityEnclosingRequest) {
request.removeHeaders(HTTP.TRANSFER_ENCODING);
request.removeHeaders(HTTP.CONTENT_LEN);
}
}
});
return new HttpComponentsClientHttpRequestFactory(httpClientBuilder.build());
}
开发者ID:JetBrains,项目名称:teamcity-hashicorp-vault-plugin,代码行数:43,代码来源:ClientHttpRequestFactoryFactory.java
示例13: SdkProxyRoutePlanner
import org.apache.http.impl.conn.DefaultSchemePortResolver; //导入依赖的package包/类
public SdkProxyRoutePlanner(String proxyHost, int proxyPort, Set<String> nonProxyHosts) {
super(DefaultSchemePortResolver.INSTANCE);
proxy = new HttpHost(proxyHost, proxyPort);
this.hostPatterns = nonProxyHosts;
}
示例14: SdkProxyRoutePlanner
import org.apache.http.impl.conn.DefaultSchemePortResolver; //导入依赖的package包/类
public SdkProxyRoutePlanner(String proxyHost, int proxyPort, String nonProxyHosts) {
super(DefaultSchemePortResolver.INSTANCE);
proxy = new HttpHost(proxyHost, proxyPort);
parseNonProxyHosts(nonProxyHosts);
}
示例15: DefaultHostRoutePlanner
import org.apache.http.impl.conn.DefaultSchemePortResolver; //导入依赖的package包/类
public DefaultHostRoutePlanner(String defaultHost) {
super(DefaultSchemePortResolver.INSTANCE);
this.defaultHost = new HttpHost(defaultHost);
}