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


Java HttpConnectionFactory类代码示例

本文整理汇总了Java中org.apache.http.conn.HttpConnectionFactory的典型用法代码示例。如果您正苦于以下问题:Java HttpConnectionFactory类的具体用法?Java HttpConnectionFactory怎么用?Java HttpConnectionFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HttpConnectionFactory类属于org.apache.http.conn包,在下文中一共展示了HttpConnectionFactory类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ProxyClient

import org.apache.http.conn.HttpConnectionFactory; //导入依赖的package包/类
/**
 * @since 4.3
 */
public ProxyClient(
        final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
        final ConnectionConfig connectionConfig,
        final RequestConfig requestConfig) {
    super();
    this.connFactory = connFactory != null ? connFactory : ManagedHttpClientConnectionFactory.INSTANCE;
    this.connectionConfig = connectionConfig != null ? connectionConfig : ConnectionConfig.DEFAULT;
    this.requestConfig = requestConfig != null ? requestConfig : RequestConfig.DEFAULT;
    this.httpProcessor = new ImmutableHttpProcessor(
            new RequestTargetHostHC4(), new RequestClientConnControl(), new RequestUserAgentHC4());
    this.requestExec = new HttpRequestExecutor();
    this.proxyAuthStrategy = new ProxyAuthenticationStrategy();
    this.authenticator = new HttpAuthenticator();
    this.proxyAuthState = new AuthStateHC4();
    this.authSchemeRegistry = new AuthSchemeRegistry();
    this.authSchemeRegistry.register(AuthSchemes.BASIC, new BasicSchemeFactoryHC4());
    this.authSchemeRegistry.register(AuthSchemes.DIGEST, new DigestSchemeFactoryHC4());
    this.authSchemeRegistry.register(AuthSchemes.NTLM, new NTLMSchemeFactory());
    this.reuseStrategy = new DefaultConnectionReuseStrategyHC4();
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:24,代码来源:ProxyClient.java

示例2: ProxyClient

import org.apache.http.conn.HttpConnectionFactory; //导入依赖的package包/类
/**
 * @since 4.3
 */
public ProxyClient(
        final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
        final ConnectionConfig connectionConfig,
        final RequestConfig requestConfig) {
    super();
    this.connFactory = connFactory != null ? connFactory : ManagedHttpClientConnectionFactory.INSTANCE;
    this.connectionConfig = connectionConfig != null ? connectionConfig : ConnectionConfig.DEFAULT;
    this.requestConfig = requestConfig != null ? requestConfig : RequestConfig.DEFAULT;
    this.httpProcessor = new ImmutableHttpProcessor(
            new RequestTargetHost(), new RequestClientConnControl(), new RequestUserAgent());
    this.requestExec = new HttpRequestExecutor();
    this.proxyAuthStrategy = new ProxyAuthenticationStrategy();
    this.authenticator = new HttpAuthenticator();
    this.proxyAuthState = new AuthState();
    this.authSchemeRegistry = new AuthSchemeRegistry();
    this.authSchemeRegistry.register(AuthSchemes.BASIC, new BasicSchemeFactory());
    this.authSchemeRegistry.register(AuthSchemes.DIGEST, new DigestSchemeFactory());
    this.authSchemeRegistry.register(AuthSchemes.NTLM, new NTLMSchemeFactory());
    this.authSchemeRegistry.register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory());
    this.authSchemeRegistry.register(AuthSchemes.KERBEROS, new KerberosSchemeFactory());
    this.reuseStrategy = new DefaultConnectionReuseStrategy();
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:26,代码来源:ProxyClient.java

示例3: buildClient

import org.apache.http.conn.HttpConnectionFactory; //导入依赖的package包/类
@Override
protected ExecREST buildClient(RESTPool pool) throws IOException {
    SSLContext sslContext;
    try {
        sslContext = SSLContext.getDefault();
    } catch (NoSuchAlgorithmException e) {
        throw new IOException(e);
    }

    Registry<ConnectionSocketFactory> socketRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
            .register("http", PlainConnectionSocketFactory.INSTANCE)
            .register("https", new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE))
            .build();

    //TODO buffers size
    SocketConfig socketConfig = SocketConfig.custom()
            .setSoTimeout(new Long(pool.getSocketTimeout()).intValue())
            .setTcpNoDelay(true)
            .setSoKeepAlive(true)
            .setSoReuseAddress(true)
            .build();

    ConnectionConfig connectionConfig = ConnectionConfig.custom()
            .setCharset(StandardCharsets.UTF_8)
            .setMalformedInputAction(CodingErrorAction.IGNORE)
            .setUnmappableInputAction(CodingErrorAction.IGNORE)
            .build();

    HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory = new ManagedHttpClientConnectionFactory(
            new DefaultHttpRequestWriterFactory(),
            new DefaultHttpResponseParserFactory()
    );

    RequestConfig requestConfig = RequestConfig.custom()
            .setConnectionRequestTimeout(new Long(pool.getMaxPoolWait()).intValue())
            .setConnectTimeout(new Long(pool.getConnectionTimeout()).intValue())
            .setExpectContinueEnabled(pool.expectContinue())
            .build();


    PoolingHttpClientConnectionManager ccm = new PoolingHttpClientConnectionManager(socketRegistry, connFactory);

    ccm.setMaxTotal(pool.getMaxTotal());
    ccm.setDefaultMaxPerRoute(pool.getMaxPerRoute());
    ccm.setDefaultSocketConfig(socketConfig);
    ccm.setDefaultConnectionConfig(connectionConfig);
    ccm.setValidateAfterInactivity(pool.getValidationOnInactivity());

    HttpClientBuilder builder = HttpClients.custom()
            .setConnectionManager(ccm)
            .setDefaultRequestConfig(requestConfig)
            .disableAutomaticRetries()
            .setKeepAliveStrategy(DefaultConnectionKeepAliveStrategy.INSTANCE)
            .disableCookieManagement()
            .disableContentCompression();

    addProxy(pool, builder);

    handleRedirects(pool, builder);

    CloseableHttpClient servClient = builder.build();

    IdleConnectionEvictor evictor = new IdleConnectionEvictor(ccm, pool.getEvictorSleep(), TimeUnit.MILLISECONDS, pool.getMaxIdleTime(), TimeUnit.MILLISECONDS);

    HTTPCClientMonitor monitor = pool.hasConnectionMetrics() ? new HTTPCSyncClientMonitor(pool.getName(), ccm) : null;

    return new HTTPCClient(servClient, evictor, monitor);
}
 
开发者ID:mercadolibre,项目名称:java-restclient,代码行数:69,代码来源:HTTPCBuilder.java

示例4: setUp

import org.apache.http.conn.HttpConnectionFactory; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    reactor = new NioReactor();

    crusher = TcpCrusherBuilder.builder()
            .withReactor(reactor)
            .withBindAddress("127.0.0.1", CRUSHER_PORT)
            .withConnectAddress(REMOTE_HOST, REMOTE_PORT)
            .buildAndOpen();

    DnsResolver dnsResolver = new SystemDefaultDnsResolver() {
        @Override
        public InetAddress[] resolve(final String host) throws UnknownHostException {
            if (host.equalsIgnoreCase(REMOTE_HOST)) {
                return new InetAddress[] { InetAddress.getByAddress(new byte[] {127, 0, 0, 1}) };
            } else {
                return super.resolve(host);
            }
        }
    };

    HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> httpConnectionFactory =
            new ManagedHttpClientConnectionFactory();

    Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
            .register("http", PlainConnectionSocketFactory.INSTANCE)
            .build();

    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(
            socketFactoryRegistry, httpConnectionFactory, dnsResolver);

    http = HttpClients.createMinimal(connectionManager);
}
 
开发者ID:NetCrusherOrg,项目名称:netcrusher-java,代码行数:34,代码来源:HttpClientTest.java

示例5: BasicHttpClientConnectionManager

import org.apache.http.conn.HttpConnectionFactory; //导入依赖的package包/类
public BasicHttpClientConnectionManager(
        final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
        final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
        final SchemePortResolver schemePortResolver,
        final DnsResolver dnsResolver) {
    super();
    this.connectionOperator = new HttpClientConnectionOperator(
            socketFactoryRegistry, schemePortResolver, dnsResolver);
    this.connFactory = connFactory != null ? connFactory : ManagedHttpClientConnectionFactory.INSTANCE;
    this.expiry = Long.MAX_VALUE;
    this.socketConfig = SocketConfig.DEFAULT;
    this.connConfig = ConnectionConfig.DEFAULT;
    this.isShutdown = new AtomicBoolean(false);
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:15,代码来源:BasicHttpClientConnectionManager.java

示例6: PoolingHttpClientConnectionManager

import org.apache.http.conn.HttpConnectionFactory; //导入依赖的package包/类
public PoolingHttpClientConnectionManager(
        final Registry<ConnectionSocketFactory> socketFactoryRegistry,
        final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
        final SchemePortResolver schemePortResolver,
        final DnsResolver dnsResolver,
        final long timeToLive, final TimeUnit tunit) {
    super();
    this.configData = new ConfigData();
    this.pool = new CPool(
            new InternalConnectionFactory(this.configData, connFactory), 2, 20, timeToLive, tunit);
    this.connectionOperator = new HttpClientConnectionOperator(
            socketFactoryRegistry, schemePortResolver, dnsResolver);
    this.isShutDown = new AtomicBoolean(false);
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:15,代码来源:PoolingHttpClientConnectionManager.java

示例7: InternalConnectionFactory

import org.apache.http.conn.HttpConnectionFactory; //导入依赖的package包/类
InternalConnectionFactory(
        final ConfigData configData,
        final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory) {
    super();
    this.configData = configData != null ? configData : new ConfigData();
    this.connFactory = connFactory != null ? connFactory :
        ManagedHttpClientConnectionFactory.INSTANCE;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:9,代码来源:PoolingHttpClientConnectionManager.java

示例8: BasicHttpClientConnectionManager

import org.apache.http.conn.HttpConnectionFactory; //导入依赖的package包/类
public BasicHttpClientConnectionManager(
    final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
    final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
    final SchemePortResolver schemePortResolver,
    final DnsResolver dnsResolver) {
  this(
      new DefaultHttpClientConnectionOperator(socketFactoryRegistry, schemePortResolver, dnsResolver),
      connFactory
  );
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:11,代码来源:BasicHttpClientConnectionManager.java

示例9: PoolingHttpClientConnectionManager

import org.apache.http.conn.HttpConnectionFactory; //导入依赖的package包/类
public PoolingHttpClientConnectionManager(
        final Registry<ConnectionSocketFactory> socketFactoryRegistry,
        final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
        final SchemePortResolver schemePortResolver,
        final DnsResolver dnsResolver,
        final long timeToLive, final TimeUnit tunit) {
    this(
        new DefaultHttpClientConnectionOperator(socketFactoryRegistry, schemePortResolver, dnsResolver),
        connFactory,
        timeToLive, tunit
    );
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:13,代码来源:PoolingHttpClientConnectionManager.java


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