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


Java DefaultSchemePortResolver类代码示例

本文整理汇总了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;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:22,代码来源:ApacheConnectionManagerFactory.java

示例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;
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:20,代码来源:ApacheConnectionManagerFactory.java

示例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;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:14,代码来源:UDTProxyConfigurator.java

示例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());
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:36,代码来源:ClientHttpRequestFactoryFactory.java

示例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;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:12,代码来源:BasicAuthCache.java

示例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);
}
 
开发者ID:bastion-dev,项目名称:Bastion,代码行数:10,代码来源:TestWithProxiedEmbeddedServer.java

示例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);
            }
        }
    };
}
 
开发者ID:bastion-dev,项目名称:Bastion,代码行数:13,代码来源:TestWithProxiedEmbeddedServer.java

示例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
    );
}
 
开发者ID:bastion-dev,项目名称:Bastion,代码行数:12,代码来源:TestWithProxiedEmbeddedServer.java

示例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;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:12,代码来源:BasicAuthCache.java

示例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;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:11,代码来源:NexusHttpRoutePlanner.java

示例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();
        }
    }
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:31,代码来源:SSLTruststoreUtil.java

示例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;
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:6,代码来源:SdkProxyRoutePlanner.java

示例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);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:6,代码来源:SdkProxyRoutePlanner.java

示例15: DefaultHostRoutePlanner

import org.apache.http.impl.conn.DefaultSchemePortResolver; //导入依赖的package包/类
public DefaultHostRoutePlanner(String defaultHost) {
    super(DefaultSchemePortResolver.INSTANCE);
    this.defaultHost = new HttpHost(defaultHost);
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:5,代码来源:HttpClientConfigurator.java


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