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


Java DefaultConnectionReuseStrategy类代码示例

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


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

示例1: ProxyClient

import org.apache.http.impl.DefaultConnectionReuseStrategy; //导入依赖的package包/类
public ProxyClient(final HttpParams params) {
    super();
    if (params == null) {
        throw new IllegalArgumentException("HTTP parameters may not be null");
    }
    this.httpProcessor = new ImmutableHttpProcessor(new HttpRequestInterceptor[] {
            new RequestContent(),
            new RequestTargetHost(),
            new RequestClientConnControl(),
            new RequestUserAgent(),
            new RequestProxyAuthentication()
    } );
    this.requestExec = new HttpRequestExecutor();
    this.proxyAuthStrategy = new ProxyAuthenticationStrategy();
    this.authenticator = new HttpAuthenticator();
    this.proxyAuthState = new AuthState();
    this.authSchemeRegistry = new AuthSchemeRegistry();
    this.authSchemeRegistry.register(AuthPolicy.BASIC, new BasicSchemeFactory());
    this.authSchemeRegistry.register(AuthPolicy.DIGEST, new DigestSchemeFactory());
    this.authSchemeRegistry.register(AuthPolicy.NTLM, new NTLMSchemeFactory());
    this.authSchemeRegistry.register(AuthPolicy.SPNEGO, new SPNegoSchemeFactory());
    this.authSchemeRegistry.register(AuthPolicy.KERBEROS, new KerberosSchemeFactory());
    this.reuseStrategy = new DefaultConnectionReuseStrategy();
    this.params = params;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:ProxyClient.java

示例2: getBuilder

import org.apache.http.impl.DefaultConnectionReuseStrategy; //导入依赖的package包/类
@NotNull
static HttpClientBuilder getBuilder() {
  final HttpClientBuilder builder = HttpClients.custom().setSSLContext(CertificateManager.getInstance().getSslContext()).
    setMaxConnPerRoute(100000).setConnectionReuseStrategy(DefaultConnectionReuseStrategy.INSTANCE);

  final HttpConfigurable proxyConfigurable = HttpConfigurable.getInstance();
  final List<Proxy> proxies = proxyConfigurable.getOnlyBySettingsSelector().select(URI.create(EduStepicNames.STEPIC_URL));
  final InetSocketAddress address = proxies.size() > 0 ? (InetSocketAddress)proxies.get(0).address() : null;
  if (address != null) {
    builder.setProxy(new HttpHost(address.getHostName(), address.getPort()));
  }
  final ConfirmingTrustManager trustManager = CertificateManager.getInstance().getTrustManager();
  try {
    SSLContext sslContext = SSLContext.getInstance("TLS");
    sslContext.init(null, new TrustManager[]{trustManager}, new SecureRandom());
    builder.setSSLContext(sslContext);
  }
  catch (NoSuchAlgorithmException | KeyManagementException e) {
    LOG.error(e.getMessage());
  }
  return builder;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:23,代码来源:EduStepicClient.java

示例3: QSystemHtmlInstance

import org.apache.http.impl.DefaultConnectionReuseStrategy; //导入依赖的package包/类
private QSystemHtmlInstance() {
    this.params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000).
        setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024).
        setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false).
        setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true).
        setParameter(CoreProtocolPNames.ORIGIN_SERVER, "QSystemReportHttpServer/1.1");

    // Set up the HTTP protocol processor
    final BasicHttpProcessor httpproc = new BasicHttpProcessor();
    httpproc.addInterceptor(new ResponseDate());
    httpproc.addInterceptor(new ResponseServer());
    httpproc.addInterceptor(new ResponseContent());
    httpproc.addInterceptor(new ResponseConnControl());

    // Set up request handlers
    final HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
    reqistry.register("*", new HttpQSystemReportsHandler());

    // Set up the HTTP service
    this.httpService = new HttpService(
        httpproc,
        new DefaultConnectionReuseStrategy(),
        new DefaultHttpResponseFactory(), reqistry, this.params);
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:25,代码来源:QSystemHtmlInstance.java

示例4: RequestListenerThread

import org.apache.http.impl.DefaultConnectionReuseStrategy; //导入依赖的package包/类
public RequestListenerThread(Context context) throws IOException, BindException {
	serversocket = new ServerSocket(PORT);
	params = new BasicHttpParams();
	params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000).setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
			.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
			.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true).setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpComponents/1.1");

	// Set up the HTTP protocol processor
	BasicHttpProcessor httpProcessor = new BasicHttpProcessor();
	httpProcessor.addInterceptor(new ResponseDate());
	httpProcessor.addInterceptor(new ResponseServer());
	httpProcessor.addInterceptor(new ResponseContent());
	httpProcessor.addInterceptor(new ResponseConnControl());

	// Set up the HTTP service
	this.httpService = new YaaccHttpService(httpProcessor, new DefaultConnectionReuseStrategy(), new DefaultHttpResponseFactory(), context);

}
 
开发者ID:theopenbit,项目名称:yaacc-code,代码行数:19,代码来源:YaaccUpnpServerService.java

示例5: createCloseableHttpAsyncClient

import org.apache.http.impl.DefaultConnectionReuseStrategy; //导入依赖的package包/类
private CloseableHttpAsyncClient createCloseableHttpAsyncClient() throws Exception {
        HttpAsyncClientBuilder builder = HttpAsyncClientBuilder.create();
        builder.useSystemProperties();
        builder.setSSLContext(SSLContext.getDefault());
        builder.setConnectionReuseStrategy(DefaultConnectionReuseStrategy.INSTANCE);
        builder.setMaxConnPerRoute(2);
        builder.setMaxConnTotal(2);
        builder.setDefaultRequestConfig(RequestConfig
            .custom()
            .setConnectionRequestTimeout(1000)
            .setConnectTimeout(2000)
            .setSocketTimeout(2000)
        .build()
        );
//        builder.setHttpProcessor()
        CloseableHttpAsyncClient hc = builder.build();
        hc.start();
        return hc;
    }
 
开发者ID:eeichinger,项目名称:jcurl,代码行数:20,代码来源:HCNIOEngine.java

示例6: ProxyClient

import org.apache.http.impl.DefaultConnectionReuseStrategy; //导入依赖的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

示例7: RequestListenerThread

import org.apache.http.impl.DefaultConnectionReuseStrategy; //导入依赖的package包/类
public RequestListenerThread(int port, final String docroot) throws IOException {
    this.serversocket = new ServerSocket(port);
    this.params = new SyncBasicHttpParams();
    this.params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000).setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024).setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false).setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true).setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpComponents/1.1");

    // Set up the HTTP protocol processor
    HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpResponseInterceptor[]{
        new ResponseDate(),
        new ResponseServer(),
        new ResponseContent(),
        new ResponseConnControl()
    });

    // Set up request handlers
    HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
    reqistry.register("*", new HttpFileHandler());

    // Set up the HTTP service
    this.httpService = new HttpService(
            httpproc,
            new DefaultConnectionReuseStrategy(),
            new DefaultHttpResponseFactory(),
            reqistry,
            this.params);
}
 
开发者ID:Torridity,项目名称:dsworkbench,代码行数:26,代码来源:ReportServer.java

示例8: HttpServerConnectionUpnpStream

import org.apache.http.impl.DefaultConnectionReuseStrategy; //导入依赖的package包/类
protected HttpServerConnectionUpnpStream(ProtocolFactory protocolFactory,
                                         HttpServerConnection connection,
                                         final HttpParams params) {
    super(protocolFactory);
    this.connection = connection;
    this.params = params;

    // The Date header is recommended in UDA, need to document the requirement in StreamServer interface?
    httpProcessor.addInterceptor(new ResponseDate());

    // The Server header is only required for Control so callers have to add it to UPnPMessage
    // httpProcessor.addInterceptor(new ResponseServer());

    httpProcessor.addInterceptor(new ResponseContent());
    httpProcessor.addInterceptor(new ResponseConnControl());

    httpService =
            new UpnpHttpService(
                    httpProcessor,
                    new DefaultConnectionReuseStrategy(),
                    new DefaultHttpResponseFactory()
            );
    httpService.setParams(params);
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:25,代码来源:HttpServerConnectionUpnpStream.java

示例9: ListenerThread

import org.apache.http.impl.DefaultConnectionReuseStrategy; //导入依赖的package包/类
public ListenerThread(InetAddress address, int port, HttpParams params,
		HttpRequestHandlerRegistry handlerRegistry) throws IOException {
	this.params = params;
	this.serverSocket = new ServerSocket(port, 0, address);

	BasicHttpProcessor httpproc = new BasicHttpProcessor();
	httpproc.addInterceptor(new ResponseDate());
	httpproc.addInterceptor(new ResponseServer());
	httpproc.addInterceptor(new ResponseContent());
	httpproc.addInterceptor(new ResponseConnControl());

	this.httpService = new HttpService(httpproc,
			new DefaultConnectionReuseStrategy(),
			new DefaultHttpResponseFactory());
	this.httpService.setParams(params);
	this.httpService.setHandlerResolver(handlerRegistry);
}
 
开发者ID:jasoncn90,项目名称:dlna-for-android,代码行数:18,代码来源:HttpServer.java

示例10: initHttpClient

import org.apache.http.impl.DefaultConnectionReuseStrategy; //导入依赖的package包/类
private void initHttpClient() {
    _params = new SyncBasicHttpParams();
    HttpProtocolParams.setVersion(_params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(_params, "UTF-8");
    HttpProtocolParams.setUseExpectContinue(_params, false);
    HttpProtocolParams.setHttpElementCharset(_params, "UTF-8");

    _httpproc = new ImmutableHttpProcessor(new HttpRequestInterceptor[] {
            // Required protocol interceptors
            new BasicHttpProcessor(),
            new RequestConnControl(),
            new RequestContent(),
            new RequestDate(),
            new RequestTargetHost(),
            // Recommended protocol interceptors
            new RequestUserAgent(),
            new RequestExpectContinue()
    });
    _httpexecutor = new HttpRequestExecutor();
    _httpcontext = new BasicHttpContext(null);
    _connection = new DefaultHttpClientConnection();
    _connectionStrategy = new DefaultConnectionReuseStrategy();
}
 
开发者ID:Juniper,项目名称:contrail-java-api,代码行数:24,代码来源:ApiConnectorImpl.java

示例11: createConnectionReuseStrategy

import org.apache.http.impl.DefaultConnectionReuseStrategy; //导入依赖的package包/类
@Override
protected ConnectionReuseStrategy createConnectionReuseStrategy() {
    String s = System.getProperty("http.keepAlive");
    if ("true".equalsIgnoreCase(s)) {
        return new DefaultConnectionReuseStrategy();
    } else {
        return new NoConnectionReuseStrategy();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:SystemDefaultHttpClient.java

示例12: FetchingThread

import org.apache.http.impl.DefaultConnectionReuseStrategy; //导入依赖的package包/类
/** Creates a new fetching thread.
 *
 * @param frontier a reference to the {@link Frontier}.
 * @param index  the index of this thread (only for logging purposes).
 */
public FetchingThread(final Frontier frontier, final int index) throws NoSuchAlgorithmException, IllegalArgumentException, IOException {
	setName(this.getClass().getSimpleName() + '-' + index);
	setPriority(Thread.MIN_PRIORITY); // Low priority; there will be thousands of this guys around.
	this.frontier = frontier;

	final BasicHttpClientConnectionManager connManager = new BasicHttpClientConnectionManagerWithAlternateDNS(frontier.rc.dnsResolver);
	connManager.closeIdleConnections(0, TimeUnit.MILLISECONDS);
	connManager.setConnectionConfig(ConnectionConfig.custom().setBufferSize(8 * 1024).build()); // TODO: make this configurable

	cookieStore = new BasicCookieStore();

	BasicHeader[] headers = {
		new BasicHeader("From", frontier.rc.userAgentFrom),
		new BasicHeader("Accept","text/html,application/xhtml+xml,application/xml;q=0.95,text/*;q=0.9,*/*;q=0.8")
	};

	httpClient = HttpClients.custom()
			.setSSLContext(frontier.rc.acceptAllCertificates ? TRUST_ALL_CERTIFICATES_SSL_CONTEXT : TRUST_SELF_SIGNED_SSL_CONTEXT)
			.setConnectionManager(connManager)
			.setConnectionReuseStrategy(frontier.rc.keepAliveTime == 0 ? NoConnectionReuseStrategy.INSTANCE : DefaultConnectionReuseStrategy.INSTANCE)
			.setUserAgent(frontier.rc.userAgent)
			.setDefaultCookieStore(cookieStore)
			.setDefaultHeaders(ObjectArrayList.wrap(headers))
			.build();
  		fetchData = new FetchData(frontier.rc);
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:32,代码来源:FetchingThread.java

示例13: RequestListenerThread

import org.apache.http.impl.DefaultConnectionReuseStrategy; //导入依赖的package包/类
public RequestListenerThread(int port, final String docroot) throws IOException {
    this.serversocket = new ServerSocket(port);
    this.params = new SyncBasicHttpParams();
    this.params
        .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000)
        .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
        .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
        .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
        .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpComponents/1.1");

    // Set up the HTTP protocol processor
    HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
            new ResponseDate(),
            new ResponseServer(),
            new ResponseContent(),
            new ResponseConnControl()
    });
    
    // Set up request handlers
    HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
    reqistry.register("*", new HttpFileHandler(docroot));
    
    // Set up the HTTP service
    this.httpService = new HttpService(
            httpproc, 
            new DefaultConnectionReuseStrategy(), 
            new DefaultHttpResponseFactory(),
            reqistry,
            this.params);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:31,代码来源:ElementalHttpServer.java

示例14: ProxyHandler

import org.apache.http.impl.DefaultConnectionReuseStrategy; //导入依赖的package包/类
public ProxyHandler(
        final HttpHost target,
        final HttpProcessor httpproc,
        final HttpRequestExecutor httpexecutor) {
    super();
    this.target = target;
    this.httpproc = httpproc;
    this.httpexecutor = httpexecutor;
    this.connStrategy = new DefaultConnectionReuseStrategy();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:11,代码来源:ElementalReverseProxy.java

示例15: ListenerThread

import org.apache.http.impl.DefaultConnectionReuseStrategy; //导入依赖的package包/类
public ListenerThread(final HttpRequestHandler requestHandler, final int port) {
    _executor = Executors.newCachedThreadPool(new NamedThreadFactory("Cluster-Listener"));

    try {
        _serverSocket = new ServerSocket(port);
    } catch (final IOException ioex) {
        s_logger.error("error initializing cluster service servlet container", ioex);
        return;
    }

    _params = new BasicHttpParams();
    _params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000)
           .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
           .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
           .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
           .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpComponents/1.1");

    // Set up the HTTP protocol processor
    final BasicHttpProcessor httpproc = new BasicHttpProcessor();
    httpproc.addInterceptor(new ResponseDate());
    httpproc.addInterceptor(new ResponseServer());
    httpproc.addInterceptor(new ResponseContent());
    httpproc.addInterceptor(new ResponseConnControl());

    // Set up request handlers
    final HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
    reqistry.register("/clusterservice", requestHandler);

    // Set up the HTTP service
    _httpService = new HttpService(httpproc, new DefaultConnectionReuseStrategy(), new DefaultHttpResponseFactory());
    _httpService.setParams(_params);
    _httpService.setHandlerResolver(reqistry);
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:34,代码来源:ClusterServiceServletContainer.java


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