com.squareup.okhttp.ConnectionPool Java Examples

The following examples show how to use com.squareup.okhttp.ConnectionPool. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpConnectorFactory.java    From apiman with Apache License 2.0 6 votes vote down vote up
/**
 * @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;
}
 
Example #2
Source File: HawkularMetricsClient.java    From apiman with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #3
Source File: RetrofitConfig.java    From halyard with Apache License 2.0 5 votes vote down vote up
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
OkClient okClient() {
  OkHttpClient client = okHttpClientConfig.create();
  client.setConnectionPool(new ConnectionPool(maxIdleConnections, keepAliveDurationMs));
  client.setRetryOnConnectionFailure(retryOnConnectionFailure);
  return new OkClient(client);
}
 
Example #4
Source File: RouteSelector.java    From L.TileLayer.Cordova with MIT License 5 votes vote down vote up
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());
}
 
Example #5
Source File: RouteSelector.java    From IoTgo_Android_App with MIT License 5 votes vote down vote up
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());
}
 
Example #6
Source File: RouteSelector.java    From android-discourse with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example #7
Source File: RouteSelector.java    From bluemix-parking-meter with MIT License 5 votes vote down vote up
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());
}
 
Example #8
Source File: RouteSelector.java    From reader with MIT License 5 votes vote down vote up
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());
}
 
Example #9
Source File: RouteSelector.java    From reader with MIT License 5 votes vote down vote up
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());
}
 
Example #10
Source File: RouteSelector.java    From cordova-amazon-fireos with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example #11
Source File: RouteSelector.java    From phonegapbootcampsite with MIT License 5 votes vote down vote up
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());
}
 
Example #12
Source File: RouteSelector.java    From CordovaYoutubeVideoPlayer with MIT License 5 votes vote down vote up
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());
}
 
Example #13
Source File: RouteSelector.java    From cordova-android-chromeview with Apache License 2.0 5 votes vote down vote up
public RouteSelector(Address address, URI uri, ProxySelector proxySelector, ConnectionPool pool,
    Dns dns, Set<Route> failedRoutes) {
  this.address = address;
  this.uri = uri;
  this.proxySelector = proxySelector;
  this.pool = pool;
  this.dns = dns;
  this.failedRoutes = failedRoutes;
  this.postponedRoutes = new LinkedList<Route>();

  resetNextProxy(uri, address.getProxy());
}
 
Example #14
Source File: RouteSelector.java    From wildfly-samples with MIT License 5 votes vote down vote up
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());
}
 
Example #15
Source File: RouteSelector.java    From phonegap-plugin-loading-spinner with Apache License 2.0 5 votes vote down vote up
public RouteSelector(Address address, URI uri, ProxySelector proxySelector, ConnectionPool pool,
    Dns dns, Set<Route> failedRoutes) {
  this.address = address;
  this.uri = uri;
  this.proxySelector = proxySelector;
  this.pool = pool;
  this.dns = dns;
  this.failedRoutes = failedRoutes;
  this.postponedRoutes = new LinkedList<Route>();

  resetNextProxy(uri, address.getProxy());
}
 
Example #16
Source File: RouteSelector.java    From crosswalk-cordova-android with Apache License 2.0 5 votes vote down vote up
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());
}