コード例 #1
0
ファイル: OkHttpClient.java プロジェクト: hyongbai/okhttp
 /**
  * Returns a shallow copy of this OkHttpClient that uses the system-wide default for each field
  * that hasn't been explicitly configured.
  */
 OkHttpClient copyWithDefaults() {
   OkHttpClient result = clone();
   if (result.proxySelector == null) {
     result.proxySelector = ProxySelector.getDefault();
   }
   if (result.cookieHandler == null) {
     result.cookieHandler = CookieHandler.getDefault();
   }
   if (result.cache == null && result.cacheAdapter == null) {
     // TODO: drop support for the default response cache.
     ResponseCache defaultCache = ResponseCache.getDefault();
     result.cacheAdapter = defaultCache != null ? new CacheAdapter(defaultCache) : null;
   }
   if (result.socketFactory == null) {
     result.socketFactory = SocketFactory.getDefault();
   }
   if (result.sslSocketFactory == null) {
     result.sslSocketFactory = getDefaultSSLSocketFactory();
   }
   if (result.hostnameVerifier == null) {
     result.hostnameVerifier = OkHostnameVerifier.INSTANCE;
   }
   if (result.authenticator == null) {
     result.authenticator = AuthenticatorAdapter.INSTANCE;
   }
   if (result.connectionPool == null) {
     result.connectionPool = ConnectionPool.getDefault();
   }
   if (result.protocols == null) {
     result.protocols = Util.immutableList(Protocol.HTTP_2, Protocol.SPDY_3, Protocol.HTTP_1_1);
   }
   return result;
 }