本文整理匯總了Java中com.squareup.okhttp.ConnectionPool類的典型用法代碼示例。如果您正苦於以下問題:Java ConnectionPool類的具體用法?Java ConnectionPool怎麽用?Java ConnectionPool使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ConnectionPool類屬於com.squareup.okhttp包,在下文中一共展示了ConnectionPool類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createClient
import com.squareup.okhttp.ConnectionPool; //導入依賴的package包/類
private OkHttpClient createClient() {
OkHttpClient client = new OkHttpClient();
client.setFollowProtocolRedirects(followRedirects);
if (connectTimeout != DEFAULT_TIMEOUT) {
client.setConnectTimeout(connectTimeout, SECONDS);
}
if (readTimeout != DEFAULT_TIMEOUT) {
client.setReadTimeout(readTimeout, SECONDS);
}
if (allowInsecure) {
client.setSslSocketFactory(createInsecureSslSocketFactory());
}
// If we don't set this reference, there's no way to clean shutdown persistent connections.
client.setConnectionPool(ConnectionPool.getDefault());
return client;
}
示例2: createHttpClient
import com.squareup.okhttp.ConnectionPool; //導入依賴的package包/類
/**
* @return a new http client
*/
private OkHttpClient createHttpClient() {
OkHttpClient client = new OkHttpClient();
client.setReadTimeout(connectorOptions.getReadTimeout(), TimeUnit.SECONDS);
client.setWriteTimeout(connectorOptions.getWriteTimeout(), TimeUnit.SECONDS);
client.setConnectTimeout(connectorOptions.getConnectTimeout(), TimeUnit.SECONDS);
client.setFollowRedirects(connectorOptions.isFollowRedirects());
client.setFollowSslRedirects(connectorOptions.isFollowRedirects());
client.setProxySelector(ProxySelector.getDefault());
client.setCookieHandler(CookieHandler.getDefault());
client.setCertificatePinner(CertificatePinner.DEFAULT);
client.setAuthenticator(AuthenticatorAdapter.INSTANCE);
client.setConnectionPool(ConnectionPool.getDefault());
client.setProtocols(Util.immutableList(Protocol.HTTP_1_1));
client.setConnectionSpecs(DEFAULT_CONNECTION_SPECS);
client.setSocketFactory(SocketFactory.getDefault());
Internal.instance.setNetwork(client, Network.DEFAULT);
return client;
}
示例3: HawkularMetricsClient
import com.squareup.okhttp.ConnectionPool; //導入依賴的package包/類
/**
* Constructor.
* @param metricsServer
*/
public HawkularMetricsClient(URL metricsServer) {
this.serverUrl = metricsServer;
httpClient = new OkHttpClient();
httpClient.setReadTimeout(DEFAULT_READ_TIMEOUT, TimeUnit.SECONDS);
httpClient.setWriteTimeout(DEFAULT_WRITE_TIMEOUT, TimeUnit.SECONDS);
httpClient.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT, TimeUnit.SECONDS);
httpClient.setFollowRedirects(true);
httpClient.setFollowSslRedirects(true);
httpClient.setProxySelector(ProxySelector.getDefault());
httpClient.setCookieHandler(CookieHandler.getDefault());
httpClient.setCertificatePinner(CertificatePinner.DEFAULT);
httpClient.setAuthenticator(AuthenticatorAdapter.INSTANCE);
httpClient.setConnectionPool(ConnectionPool.getDefault());
httpClient.setProtocols(Util.immutableList(Protocol.HTTP_1_1));
httpClient.setConnectionSpecs(DEFAULT_CONNECTION_SPECS);
httpClient.setSocketFactory(SocketFactory.getDefault());
Internal.instance.setNetwork(httpClient, Network.DEFAULT);
}
示例4: createDefaultHttpClient
import com.squareup.okhttp.ConnectionPool; //導入依賴的package包/類
private OkHttpClient createDefaultHttpClient() {
OkHttpClient httpClient = new OkHttpClient();
httpClient.setConnectTimeout(10, TimeUnit.SECONDS);
httpClient.setReadTimeout(10, TimeUnit.SECONDS);
httpClient.setWriteTimeout(20, TimeUnit.SECONDS);
httpClient.setConnectionPool(new ConnectionPool(20, 2 * 60 * 1000));
return httpClient;
}
示例5: RouteSelector
import com.squareup.okhttp.ConnectionPool; //導入依賴的package包/類
public RouteSelector(Address address, URI uri, ProxySelector proxySelector, ConnectionPool pool,
Dns dns, RouteDatabase routeDatabase) {
this.address = address;
this.uri = uri;
this.proxySelector = proxySelector;
this.pool = pool;
this.dns = dns;
this.routeDatabase = routeDatabase;
this.postponedRoutes = new LinkedList<Route>();
resetNextProxy(uri, address.getProxy());
}
示例6: startPollingOnChangeEndpoint
import com.squareup.okhttp.ConnectionPool; //導入依賴的package包/類
public void startPollingOnChangeEndpoint(
OnServerContentChangeListener onServerContentChangeListener) {
if (mOnChangePollingEnabled) {
// polling already enabled
return;
}
mOnChangePollingEnabled = true;
mOnServerContentChangeListener = onServerContentChangeListener;
mOnChangePollingClient = new OkHttpClient();
mOnChangePollingClient
.setConnectionPool(new ConnectionPool(1, LONG_POLL_KEEP_ALIVE_DURATION_MS))
.setConnectTimeout(HTTP_CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
enqueueOnChangeEndpointLongPolling();
}
示例7: okClient
import com.squareup.okhttp.ConnectionPool; //導入依賴的package包/類
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
OkClient okClient() {
val client = okHttpClientConfig.create();
client.setConnectionPool(new ConnectionPool(maxIdleConnections, keepAliveDurationMs));
client.setRetryOnConnectionFailure(retryOnConnectionFailure);
client.interceptors().add(new RetryingInterceptor(maxElapsedBackoffMs));
return new OkClient(client);
}
示例8: okClient
import com.squareup.okhttp.ConnectionPool; //導入依賴的package包/類
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
OkClient okClient() {
OkHttpClient client = okHttpClientConfig.create();
client.setConnectionPool(new ConnectionPool(maxIdleConnections, keepAliveDurationMs));
client.setRetryOnConnectionFailure(retryOnConnectionFailure);
return new OkClient(client);
}
示例9: HttpConnection
import com.squareup.okhttp.ConnectionPool; //導入依賴的package包/類
public HttpConnection(ConnectionPool paramConnectionPool, Connection paramConnection, Socket paramSocket)
throws IOException
{
this.pool = paramConnectionPool;
this.connection = paramConnection;
this.socket = paramSocket;
this.source = Okio.buffer(Okio.source(paramSocket));
this.sink = Okio.buffer(Okio.sink(paramSocket));
}
示例10: RouteSelector
import com.squareup.okhttp.ConnectionPool; //導入依賴的package包/類
public RouteSelector(Address address, URI uri, ProxySelector proxySelector, ConnectionPool pool, Dns dns, RouteDatabase routeDatabase) {
this.address = address;
this.uri = uri;
this.proxySelector = proxySelector;
this.pool = pool;
this.dns = dns;
this.routeDatabase = routeDatabase;
this.postponedRoutes = new LinkedList<Route>();
resetNextProxy(uri, address.getProxy());
}
示例11: provideClient
import com.squareup.okhttp.ConnectionPool; //導入依賴的package包/類
@Provides
@Singleton
Client provideClient(OkHttpClient client) {
client = new OkHttpClient();
client.setConnectTimeout(30, TimeUnit.SECONDS); // connect timeout
client.setReadTimeout(30, TimeUnit.SECONDS); // socket timeout
client.setConnectionPool(new ConnectionPool(0, 5 * 60 * 1000));
return new OkClient(client);
}