Java 类org.apache.http.impl.conn.DefaultSchemePortResolver 实例源码

项目:aws-sdk-java-v2    文件:ApacheConnectionManagerFactory.java   
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;
}
项目:ibm-cos-sdk-java    文件:ApacheConnectionManagerFactory.java   
@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;
}
项目:cyberduck    文件:UDTProxyConfigurator.java   
@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;
}
项目:spring-vault    文件:ClientHttpRequestFactoryFactory.java   
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());
}
项目:remote-files-sync    文件:BasicAuthCache.java   
/**
 * Default constructor.
 *
 * @since 4.3
 */
public BasicAuthCache(final SchemePortResolver schemePortResolver) {
    super();
    this.map = new HashMap<HttpHost, AuthScheme>();
    this.schemePortResolver = schemePortResolver != null ? schemePortResolver :
        DefaultSchemePortResolver.INSTANCE;
}
项目:Bastion    文件:TestWithProxiedEmbeddedServer.java   
@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);
}
项目:Bastion    文件:TestWithProxiedEmbeddedServer.java   
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);
            }
        }
    };
}
项目:Bastion    文件:TestWithProxiedEmbeddedServer.java   
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
    );
}
项目:purecloud-iot    文件:BasicAuthCache.java   
/**
 * Default constructor.
 *
 * @since 4.3
 */
public BasicAuthCache(final SchemePortResolver schemePortResolver) {
    super();
    this.map = new ConcurrentHashMap<HttpHost, byte[]>();
    this.schemePortResolver = schemePortResolver != null ? schemePortResolver :
        DefaultSchemePortResolver.INSTANCE;
}
项目:nexus-public    文件:NexusHttpRoutePlanner.java   
/**
 * @since 2.5
 */
public NexusHttpRoutePlanner(final Map<String, HttpHost> proxies,
                             @Nullable final Pattern nonProxyHostsPattern)
{
  super(DefaultSchemePortResolver.INSTANCE);
  this.proxies = checkNotNull(proxies);
  this.nonProxyHostPattern = nonProxyHostsPattern;
}
项目:Visit    文件:BasicAuthCache.java   
/**
 * Default constructor.
 *
 * @since 4.3
 */
public BasicAuthCache(final SchemePortResolver schemePortResolver) {
    super();
    this.map = new HashMap<HttpHost, AuthScheme>();
    this.schemePortResolver = schemePortResolver != null ? schemePortResolver :
        DefaultSchemePortResolver.INSTANCE;
}
项目:wildfly-core    文件:SSLTruststoreUtil.java   
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();
        }
    }
项目:ZTLib    文件:BasicAuthCache.java   
/**
 * Default constructor.
 *
 * @since 4.3
 */
public BasicAuthCache(final SchemePortResolver schemePortResolver) {
    super();
    this.map = new HashMap<HttpHost, AuthScheme>();
    this.schemePortResolver = schemePortResolver != null ? schemePortResolver :
        DefaultSchemePortResolver.INSTANCE;
}
项目:teamcity-hashicorp-vault-plugin    文件:ClientHttpRequestFactoryFactory.java   
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());
}
项目:aws-sdk-java-v2    文件:SdkProxyRoutePlanner.java   
public SdkProxyRoutePlanner(String proxyHost, int proxyPort, Set<String> nonProxyHosts) {
    super(DefaultSchemePortResolver.INSTANCE);
    proxy = new HttpHost(proxyHost, proxyPort);
    this.hostPatterns = nonProxyHosts;
}
项目:ibm-cos-sdk-java    文件:SdkProxyRoutePlanner.java   
public SdkProxyRoutePlanner(String proxyHost, int proxyPort, String nonProxyHosts) {
    super(DefaultSchemePortResolver.INSTANCE);
    proxy = new HttpHost(proxyHost, proxyPort);
    parseNonProxyHosts(nonProxyHosts);
}
项目:artifactory    文件:HttpClientConfigurator.java   
public DefaultHostRoutePlanner(String defaultHost) {
    super(DefaultSchemePortResolver.INSTANCE);
    this.defaultHost = new HttpHost(defaultHost);
}
项目:bintray-client-java    文件:HttpClientConfigurator.java   
public DefaultHostRoutePlanner(String defaultHost) {
    super(DefaultSchemePortResolver.INSTANCE);
    this.defaultHost = new HttpHost(defaultHost);
}
项目:AkamaiOPEN-edgegrid-java    文件:ApacheHttpClientEdgeGridRoutePlanner.java   
public ApacheHttpClientEdgeGridRoutePlanner(ClientCredential clientCredential) {
    super(DefaultSchemePortResolver.INSTANCE);
    this.binding = new ApacheHttpClientEdgeGridRequestSigner(clientCredential);
}
项目:AkamaiOPEN-edgegrid-java    文件:ApacheHttpClientEdgeGridRoutePlanner.java   
public ApacheHttpClientEdgeGridRoutePlanner(ClientCredentialProvider clientCredentialProvider) {
    super(DefaultSchemePortResolver.INSTANCE);
    this.binding = new ApacheHttpClientEdgeGridRequestSigner(clientCredentialProvider);
}