635 lines
		
	
	
		
			23 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			635 lines
		
	
	
		
			23 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package okhttp3;
 | |
| 
 | |
| import com.thoughtworks.xstream.XStream;
 | |
| import java.net.Proxy;
 | |
| import java.net.ProxySelector;
 | |
| import java.net.Socket;
 | |
| import java.security.GeneralSecurityException;
 | |
| import java.util.ArrayList;
 | |
| import java.util.Collections;
 | |
| import java.util.Iterator;
 | |
| import java.util.List;
 | |
| import java.util.Random;
 | |
| import java.util.concurrent.TimeUnit;
 | |
| import javax.net.SocketFactory;
 | |
| import javax.net.ssl.HostnameVerifier;
 | |
| import javax.net.ssl.SSLContext;
 | |
| import javax.net.ssl.SSLSocket;
 | |
| import javax.net.ssl.SSLSocketFactory;
 | |
| import javax.net.ssl.TrustManager;
 | |
| import javax.net.ssl.X509TrustManager;
 | |
| import okhttp3.Call;
 | |
| import okhttp3.EventListener;
 | |
| import okhttp3.Headers;
 | |
| import okhttp3.Response;
 | |
| import okhttp3.WebSocket;
 | |
| import okhttp3.internal.Internal;
 | |
| import okhttp3.internal.Util;
 | |
| import okhttp3.internal.cache.InternalCache;
 | |
| import okhttp3.internal.connection.RealConnection;
 | |
| import okhttp3.internal.connection.RouteDatabase;
 | |
| import okhttp3.internal.connection.StreamAllocation;
 | |
| import okhttp3.internal.platform.Platform;
 | |
| import okhttp3.internal.tls.CertificateChainCleaner;
 | |
| import okhttp3.internal.tls.OkHostnameVerifier;
 | |
| import okhttp3.internal.ws.RealWebSocket;
 | |
| 
 | |
| /* loaded from: classes2.dex */
 | |
| public class OkHttpClient implements Cloneable, Call.Factory, WebSocket.Factory {
 | |
|     final Authenticator authenticator;
 | |
|     final Cache cache;
 | |
|     final CertificateChainCleaner certificateChainCleaner;
 | |
|     final CertificatePinner certificatePinner;
 | |
|     final int connectTimeout;
 | |
|     final ConnectionPool connectionPool;
 | |
|     final List<ConnectionSpec> connectionSpecs;
 | |
|     final CookieJar cookieJar;
 | |
|     final Dispatcher dispatcher;
 | |
|     final Dns dns;
 | |
|     final EventListener.Factory eventListenerFactory;
 | |
|     final boolean followRedirects;
 | |
|     final boolean followSslRedirects;
 | |
|     final HostnameVerifier hostnameVerifier;
 | |
|     final List<Interceptor> interceptors;
 | |
|     final InternalCache internalCache;
 | |
|     final List<Interceptor> networkInterceptors;
 | |
|     final int pingInterval;
 | |
|     final List<Protocol> protocols;
 | |
|     final Proxy proxy;
 | |
|     final Authenticator proxyAuthenticator;
 | |
|     final ProxySelector proxySelector;
 | |
|     final int readTimeout;
 | |
|     final boolean retryOnConnectionFailure;
 | |
|     final SocketFactory socketFactory;
 | |
|     final SSLSocketFactory sslSocketFactory;
 | |
|     final int writeTimeout;
 | |
|     static final List<Protocol> DEFAULT_PROTOCOLS = Util.immutableList(Protocol.HTTP_2, Protocol.HTTP_1_1);
 | |
|     static final List<ConnectionSpec> DEFAULT_CONNECTION_SPECS = Util.immutableList(ConnectionSpec.MODERN_TLS, ConnectionSpec.CLEARTEXT);
 | |
| 
 | |
|     static {
 | |
|         Internal.instance = new Internal() { // from class: okhttp3.OkHttpClient.1
 | |
|             @Override // okhttp3.internal.Internal
 | |
|             public void addLenient(Headers.Builder builder, String str) {
 | |
|                 builder.addLenient(str);
 | |
|             }
 | |
| 
 | |
|             @Override // okhttp3.internal.Internal
 | |
|             public void apply(ConnectionSpec connectionSpec, SSLSocket sSLSocket, boolean z) {
 | |
|                 connectionSpec.apply(sSLSocket, z);
 | |
|             }
 | |
| 
 | |
|             @Override // okhttp3.internal.Internal
 | |
|             public int code(Response.Builder builder) {
 | |
|                 return builder.code;
 | |
|             }
 | |
| 
 | |
|             @Override // okhttp3.internal.Internal
 | |
|             public boolean connectionBecameIdle(ConnectionPool connectionPool, RealConnection realConnection) {
 | |
|                 return connectionPool.connectionBecameIdle(realConnection);
 | |
|             }
 | |
| 
 | |
|             @Override // okhttp3.internal.Internal
 | |
|             public Socket deduplicate(ConnectionPool connectionPool, Address address, StreamAllocation streamAllocation) {
 | |
|                 return connectionPool.deduplicate(address, streamAllocation);
 | |
|             }
 | |
| 
 | |
|             @Override // okhttp3.internal.Internal
 | |
|             public boolean equalsNonHost(Address address, Address address2) {
 | |
|                 return address.equalsNonHost(address2);
 | |
|             }
 | |
| 
 | |
|             @Override // okhttp3.internal.Internal
 | |
|             public RealConnection get(ConnectionPool connectionPool, Address address, StreamAllocation streamAllocation, Route route) {
 | |
|                 return connectionPool.get(address, streamAllocation, route);
 | |
|             }
 | |
| 
 | |
|             @Override // okhttp3.internal.Internal
 | |
|             public boolean isInvalidHttpUrlHost(IllegalArgumentException illegalArgumentException) {
 | |
|                 return illegalArgumentException.getMessage().startsWith("Invalid URL host");
 | |
|             }
 | |
| 
 | |
|             @Override // okhttp3.internal.Internal
 | |
|             public Call newWebSocketCall(OkHttpClient okHttpClient, Request request) {
 | |
|                 return RealCall.newRealCall(okHttpClient, request, true);
 | |
|             }
 | |
| 
 | |
|             @Override // okhttp3.internal.Internal
 | |
|             public void put(ConnectionPool connectionPool, RealConnection realConnection) {
 | |
|                 connectionPool.put(realConnection);
 | |
|             }
 | |
| 
 | |
|             @Override // okhttp3.internal.Internal
 | |
|             public RouteDatabase routeDatabase(ConnectionPool connectionPool) {
 | |
|                 return connectionPool.routeDatabase;
 | |
|             }
 | |
| 
 | |
|             @Override // okhttp3.internal.Internal
 | |
|             public void setCache(Builder builder, InternalCache internalCache) {
 | |
|                 builder.setInternalCache(internalCache);
 | |
|             }
 | |
| 
 | |
|             @Override // okhttp3.internal.Internal
 | |
|             public StreamAllocation streamAllocation(Call call) {
 | |
|                 return ((RealCall) call).streamAllocation();
 | |
|             }
 | |
| 
 | |
|             @Override // okhttp3.internal.Internal
 | |
|             public void addLenient(Headers.Builder builder, String str, String str2) {
 | |
|                 builder.addLenient(str, str2);
 | |
|             }
 | |
|         };
 | |
|     }
 | |
| 
 | |
|     public OkHttpClient() {
 | |
|         this(new Builder());
 | |
|     }
 | |
| 
 | |
|     private static SSLSocketFactory newSslSocketFactory(X509TrustManager x509TrustManager) {
 | |
|         try {
 | |
|             SSLContext sSLContext = Platform.get().getSSLContext();
 | |
|             sSLContext.init(null, new TrustManager[]{x509TrustManager}, null);
 | |
|             return sSLContext.getSocketFactory();
 | |
|         } catch (GeneralSecurityException e) {
 | |
|             throw Util.assertionError("No System TLS", e);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public Authenticator authenticator() {
 | |
|         return this.authenticator;
 | |
|     }
 | |
| 
 | |
|     public Cache cache() {
 | |
|         return this.cache;
 | |
|     }
 | |
| 
 | |
|     public CertificatePinner certificatePinner() {
 | |
|         return this.certificatePinner;
 | |
|     }
 | |
| 
 | |
|     public int connectTimeoutMillis() {
 | |
|         return this.connectTimeout;
 | |
|     }
 | |
| 
 | |
|     public ConnectionPool connectionPool() {
 | |
|         return this.connectionPool;
 | |
|     }
 | |
| 
 | |
|     public List<ConnectionSpec> connectionSpecs() {
 | |
|         return this.connectionSpecs;
 | |
|     }
 | |
| 
 | |
|     public CookieJar cookieJar() {
 | |
|         return this.cookieJar;
 | |
|     }
 | |
| 
 | |
|     public Dispatcher dispatcher() {
 | |
|         return this.dispatcher;
 | |
|     }
 | |
| 
 | |
|     public Dns dns() {
 | |
|         return this.dns;
 | |
|     }
 | |
| 
 | |
|     public EventListener.Factory eventListenerFactory() {
 | |
|         return this.eventListenerFactory;
 | |
|     }
 | |
| 
 | |
|     public boolean followRedirects() {
 | |
|         return this.followRedirects;
 | |
|     }
 | |
| 
 | |
|     public boolean followSslRedirects() {
 | |
|         return this.followSslRedirects;
 | |
|     }
 | |
| 
 | |
|     public HostnameVerifier hostnameVerifier() {
 | |
|         return this.hostnameVerifier;
 | |
|     }
 | |
| 
 | |
|     public List<Interceptor> interceptors() {
 | |
|         return this.interceptors;
 | |
|     }
 | |
| 
 | |
|     InternalCache internalCache() {
 | |
|         Cache cache = this.cache;
 | |
|         return cache != null ? cache.internalCache : this.internalCache;
 | |
|     }
 | |
| 
 | |
|     public List<Interceptor> networkInterceptors() {
 | |
|         return this.networkInterceptors;
 | |
|     }
 | |
| 
 | |
|     public Builder newBuilder() {
 | |
|         return new Builder(this);
 | |
|     }
 | |
| 
 | |
|     @Override // okhttp3.Call.Factory
 | |
|     public Call newCall(Request request) {
 | |
|         return RealCall.newRealCall(this, request, false);
 | |
|     }
 | |
| 
 | |
|     @Override // okhttp3.WebSocket.Factory
 | |
|     public WebSocket newWebSocket(Request request, WebSocketListener webSocketListener) {
 | |
|         RealWebSocket realWebSocket = new RealWebSocket(request, webSocketListener, new Random(), this.pingInterval);
 | |
|         realWebSocket.connect(this);
 | |
|         return realWebSocket;
 | |
|     }
 | |
| 
 | |
|     public int pingIntervalMillis() {
 | |
|         return this.pingInterval;
 | |
|     }
 | |
| 
 | |
|     public List<Protocol> protocols() {
 | |
|         return this.protocols;
 | |
|     }
 | |
| 
 | |
|     public Proxy proxy() {
 | |
|         return this.proxy;
 | |
|     }
 | |
| 
 | |
|     public Authenticator proxyAuthenticator() {
 | |
|         return this.proxyAuthenticator;
 | |
|     }
 | |
| 
 | |
|     public ProxySelector proxySelector() {
 | |
|         return this.proxySelector;
 | |
|     }
 | |
| 
 | |
|     public int readTimeoutMillis() {
 | |
|         return this.readTimeout;
 | |
|     }
 | |
| 
 | |
|     public boolean retryOnConnectionFailure() {
 | |
|         return this.retryOnConnectionFailure;
 | |
|     }
 | |
| 
 | |
|     public SocketFactory socketFactory() {
 | |
|         return this.socketFactory;
 | |
|     }
 | |
| 
 | |
|     public SSLSocketFactory sslSocketFactory() {
 | |
|         return this.sslSocketFactory;
 | |
|     }
 | |
| 
 | |
|     public int writeTimeoutMillis() {
 | |
|         return this.writeTimeout;
 | |
|     }
 | |
| 
 | |
|     OkHttpClient(Builder builder) {
 | |
|         boolean z;
 | |
|         this.dispatcher = builder.dispatcher;
 | |
|         this.proxy = builder.proxy;
 | |
|         this.protocols = builder.protocols;
 | |
|         this.connectionSpecs = builder.connectionSpecs;
 | |
|         this.interceptors = Util.immutableList(builder.interceptors);
 | |
|         this.networkInterceptors = Util.immutableList(builder.networkInterceptors);
 | |
|         this.eventListenerFactory = builder.eventListenerFactory;
 | |
|         this.proxySelector = builder.proxySelector;
 | |
|         this.cookieJar = builder.cookieJar;
 | |
|         this.cache = builder.cache;
 | |
|         this.internalCache = builder.internalCache;
 | |
|         this.socketFactory = builder.socketFactory;
 | |
|         Iterator<ConnectionSpec> it = this.connectionSpecs.iterator();
 | |
|         loop0: while (true) {
 | |
|             while (it.hasNext()) {
 | |
|                 z = z || it.next().isTls();
 | |
|             }
 | |
|         }
 | |
|         if (builder.sslSocketFactory == null && z) {
 | |
|             X509TrustManager platformTrustManager = Util.platformTrustManager();
 | |
|             this.sslSocketFactory = newSslSocketFactory(platformTrustManager);
 | |
|             this.certificateChainCleaner = CertificateChainCleaner.get(platformTrustManager);
 | |
|         } else {
 | |
|             this.sslSocketFactory = builder.sslSocketFactory;
 | |
|             this.certificateChainCleaner = builder.certificateChainCleaner;
 | |
|         }
 | |
|         if (this.sslSocketFactory != null) {
 | |
|             Platform.get().configureSslSocketFactory(this.sslSocketFactory);
 | |
|         }
 | |
|         this.hostnameVerifier = builder.hostnameVerifier;
 | |
|         this.certificatePinner = builder.certificatePinner.withCertificateChainCleaner(this.certificateChainCleaner);
 | |
|         this.proxyAuthenticator = builder.proxyAuthenticator;
 | |
|         this.authenticator = builder.authenticator;
 | |
|         this.connectionPool = builder.connectionPool;
 | |
|         this.dns = builder.dns;
 | |
|         this.followSslRedirects = builder.followSslRedirects;
 | |
|         this.followRedirects = builder.followRedirects;
 | |
|         this.retryOnConnectionFailure = builder.retryOnConnectionFailure;
 | |
|         this.connectTimeout = builder.connectTimeout;
 | |
|         this.readTimeout = builder.readTimeout;
 | |
|         this.writeTimeout = builder.writeTimeout;
 | |
|         this.pingInterval = builder.pingInterval;
 | |
|         if (this.interceptors.contains(null)) {
 | |
|             throw new IllegalStateException("Null interceptor: " + this.interceptors);
 | |
|         }
 | |
|         if (this.networkInterceptors.contains(null)) {
 | |
|             throw new IllegalStateException("Null network interceptor: " + this.networkInterceptors);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public static final class Builder {
 | |
|         Authenticator authenticator;
 | |
|         Cache cache;
 | |
|         CertificateChainCleaner certificateChainCleaner;
 | |
|         CertificatePinner certificatePinner;
 | |
|         int connectTimeout;
 | |
|         ConnectionPool connectionPool;
 | |
|         List<ConnectionSpec> connectionSpecs;
 | |
|         CookieJar cookieJar;
 | |
|         Dispatcher dispatcher;
 | |
|         Dns dns;
 | |
|         EventListener.Factory eventListenerFactory;
 | |
|         boolean followRedirects;
 | |
|         boolean followSslRedirects;
 | |
|         HostnameVerifier hostnameVerifier;
 | |
|         final List<Interceptor> interceptors;
 | |
|         InternalCache internalCache;
 | |
|         final List<Interceptor> networkInterceptors;
 | |
|         int pingInterval;
 | |
|         List<Protocol> protocols;
 | |
|         Proxy proxy;
 | |
|         Authenticator proxyAuthenticator;
 | |
|         ProxySelector proxySelector;
 | |
|         int readTimeout;
 | |
|         boolean retryOnConnectionFailure;
 | |
|         SocketFactory socketFactory;
 | |
|         SSLSocketFactory sslSocketFactory;
 | |
|         int writeTimeout;
 | |
| 
 | |
|         public Builder() {
 | |
|             this.interceptors = new ArrayList();
 | |
|             this.networkInterceptors = new ArrayList();
 | |
|             this.dispatcher = new Dispatcher();
 | |
|             this.protocols = OkHttpClient.DEFAULT_PROTOCOLS;
 | |
|             this.connectionSpecs = OkHttpClient.DEFAULT_CONNECTION_SPECS;
 | |
|             this.eventListenerFactory = EventListener.factory(EventListener.NONE);
 | |
|             this.proxySelector = ProxySelector.getDefault();
 | |
|             this.cookieJar = CookieJar.NO_COOKIES;
 | |
|             this.socketFactory = SocketFactory.getDefault();
 | |
|             this.hostnameVerifier = OkHostnameVerifier.INSTANCE;
 | |
|             this.certificatePinner = CertificatePinner.DEFAULT;
 | |
|             Authenticator authenticator = Authenticator.NONE;
 | |
|             this.proxyAuthenticator = authenticator;
 | |
|             this.authenticator = authenticator;
 | |
|             this.connectionPool = new ConnectionPool();
 | |
|             this.dns = Dns.SYSTEM;
 | |
|             this.followSslRedirects = true;
 | |
|             this.followRedirects = true;
 | |
|             this.retryOnConnectionFailure = true;
 | |
|             this.connectTimeout = XStream.PRIORITY_VERY_HIGH;
 | |
|             this.readTimeout = XStream.PRIORITY_VERY_HIGH;
 | |
|             this.writeTimeout = XStream.PRIORITY_VERY_HIGH;
 | |
|             this.pingInterval = 0;
 | |
|         }
 | |
| 
 | |
|         public Builder addInterceptor(Interceptor interceptor) {
 | |
|             if (interceptor == null) {
 | |
|                 throw new IllegalArgumentException("interceptor == null");
 | |
|             }
 | |
|             this.interceptors.add(interceptor);
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder addNetworkInterceptor(Interceptor interceptor) {
 | |
|             if (interceptor == null) {
 | |
|                 throw new IllegalArgumentException("interceptor == null");
 | |
|             }
 | |
|             this.networkInterceptors.add(interceptor);
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder authenticator(Authenticator authenticator) {
 | |
|             if (authenticator == null) {
 | |
|                 throw new NullPointerException("authenticator == null");
 | |
|             }
 | |
|             this.authenticator = authenticator;
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public OkHttpClient build() {
 | |
|             return new OkHttpClient(this);
 | |
|         }
 | |
| 
 | |
|         public Builder cache(Cache cache) {
 | |
|             this.cache = cache;
 | |
|             this.internalCache = null;
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder certificatePinner(CertificatePinner certificatePinner) {
 | |
|             if (certificatePinner == null) {
 | |
|                 throw new NullPointerException("certificatePinner == null");
 | |
|             }
 | |
|             this.certificatePinner = certificatePinner;
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder connectTimeout(long j, TimeUnit timeUnit) {
 | |
|             this.connectTimeout = Util.checkDuration("timeout", j, timeUnit);
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder connectionPool(ConnectionPool connectionPool) {
 | |
|             if (connectionPool == null) {
 | |
|                 throw new NullPointerException("connectionPool == null");
 | |
|             }
 | |
|             this.connectionPool = connectionPool;
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder connectionSpecs(List<ConnectionSpec> list) {
 | |
|             this.connectionSpecs = Util.immutableList(list);
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder cookieJar(CookieJar cookieJar) {
 | |
|             if (cookieJar == null) {
 | |
|                 throw new NullPointerException("cookieJar == null");
 | |
|             }
 | |
|             this.cookieJar = cookieJar;
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder dispatcher(Dispatcher dispatcher) {
 | |
|             if (dispatcher == null) {
 | |
|                 throw new IllegalArgumentException("dispatcher == null");
 | |
|             }
 | |
|             this.dispatcher = dispatcher;
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder dns(Dns dns) {
 | |
|             if (dns == null) {
 | |
|                 throw new NullPointerException("dns == null");
 | |
|             }
 | |
|             this.dns = dns;
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder eventListener(EventListener eventListener) {
 | |
|             if (eventListener == null) {
 | |
|                 throw new NullPointerException("eventListener == null");
 | |
|             }
 | |
|             this.eventListenerFactory = EventListener.factory(eventListener);
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder eventListenerFactory(EventListener.Factory factory) {
 | |
|             if (factory == null) {
 | |
|                 throw new NullPointerException("eventListenerFactory == null");
 | |
|             }
 | |
|             this.eventListenerFactory = factory;
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder followRedirects(boolean z) {
 | |
|             this.followRedirects = z;
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder followSslRedirects(boolean z) {
 | |
|             this.followSslRedirects = z;
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder hostnameVerifier(HostnameVerifier hostnameVerifier) {
 | |
|             if (hostnameVerifier == null) {
 | |
|                 throw new NullPointerException("hostnameVerifier == null");
 | |
|             }
 | |
|             this.hostnameVerifier = hostnameVerifier;
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public List<Interceptor> interceptors() {
 | |
|             return this.interceptors;
 | |
|         }
 | |
| 
 | |
|         public List<Interceptor> networkInterceptors() {
 | |
|             return this.networkInterceptors;
 | |
|         }
 | |
| 
 | |
|         public Builder pingInterval(long j, TimeUnit timeUnit) {
 | |
|             this.pingInterval = Util.checkDuration("interval", j, timeUnit);
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder protocols(List<Protocol> list) {
 | |
|             ArrayList arrayList = new ArrayList(list);
 | |
|             if (!arrayList.contains(Protocol.H2_PRIOR_KNOWLEDGE) && !arrayList.contains(Protocol.HTTP_1_1)) {
 | |
|                 throw new IllegalArgumentException("protocols must contain h2_prior_knowledge or http/1.1: " + arrayList);
 | |
|             }
 | |
|             if (arrayList.contains(Protocol.H2_PRIOR_KNOWLEDGE) && arrayList.size() > 1) {
 | |
|                 throw new IllegalArgumentException("protocols containing h2_prior_knowledge cannot use other protocols: " + arrayList);
 | |
|             }
 | |
|             if (arrayList.contains(Protocol.HTTP_1_0)) {
 | |
|                 throw new IllegalArgumentException("protocols must not contain http/1.0: " + arrayList);
 | |
|             }
 | |
|             if (arrayList.contains(null)) {
 | |
|                 throw new IllegalArgumentException("protocols must not contain null");
 | |
|             }
 | |
|             arrayList.remove(Protocol.SPDY_3);
 | |
|             this.protocols = Collections.unmodifiableList(arrayList);
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder proxy(Proxy proxy) {
 | |
|             this.proxy = proxy;
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder proxyAuthenticator(Authenticator authenticator) {
 | |
|             if (authenticator == null) {
 | |
|                 throw new NullPointerException("proxyAuthenticator == null");
 | |
|             }
 | |
|             this.proxyAuthenticator = authenticator;
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder proxySelector(ProxySelector proxySelector) {
 | |
|             this.proxySelector = proxySelector;
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder readTimeout(long j, TimeUnit timeUnit) {
 | |
|             this.readTimeout = Util.checkDuration("timeout", j, timeUnit);
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder retryOnConnectionFailure(boolean z) {
 | |
|             this.retryOnConnectionFailure = z;
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         void setInternalCache(InternalCache internalCache) {
 | |
|             this.internalCache = internalCache;
 | |
|             this.cache = null;
 | |
|         }
 | |
| 
 | |
|         public Builder socketFactory(SocketFactory socketFactory) {
 | |
|             if (socketFactory == null) {
 | |
|                 throw new NullPointerException("socketFactory == null");
 | |
|             }
 | |
|             this.socketFactory = socketFactory;
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder sslSocketFactory(SSLSocketFactory sSLSocketFactory) {
 | |
|             if (sSLSocketFactory == null) {
 | |
|                 throw new NullPointerException("sslSocketFactory == null");
 | |
|             }
 | |
|             this.sslSocketFactory = sSLSocketFactory;
 | |
|             this.certificateChainCleaner = Platform.get().buildCertificateChainCleaner(sSLSocketFactory);
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder writeTimeout(long j, TimeUnit timeUnit) {
 | |
|             this.writeTimeout = Util.checkDuration("timeout", j, timeUnit);
 | |
|             return this;
 | |
|         }
 | |
| 
 | |
|         public Builder sslSocketFactory(SSLSocketFactory sSLSocketFactory, X509TrustManager x509TrustManager) {
 | |
|             if (sSLSocketFactory == null) {
 | |
|                 throw new NullPointerException("sslSocketFactory == null");
 | |
|             }
 | |
|             if (x509TrustManager != null) {
 | |
|                 this.sslSocketFactory = sSLSocketFactory;
 | |
|                 this.certificateChainCleaner = CertificateChainCleaner.get(x509TrustManager);
 | |
|                 return this;
 | |
|             }
 | |
|             throw new NullPointerException("trustManager == null");
 | |
|         }
 | |
| 
 | |
|         Builder(OkHttpClient okHttpClient) {
 | |
|             this.interceptors = new ArrayList();
 | |
|             this.networkInterceptors = new ArrayList();
 | |
|             this.dispatcher = okHttpClient.dispatcher;
 | |
|             this.proxy = okHttpClient.proxy;
 | |
|             this.protocols = okHttpClient.protocols;
 | |
|             this.connectionSpecs = okHttpClient.connectionSpecs;
 | |
|             this.interceptors.addAll(okHttpClient.interceptors);
 | |
|             this.networkInterceptors.addAll(okHttpClient.networkInterceptors);
 | |
|             this.eventListenerFactory = okHttpClient.eventListenerFactory;
 | |
|             this.proxySelector = okHttpClient.proxySelector;
 | |
|             this.cookieJar = okHttpClient.cookieJar;
 | |
|             this.internalCache = okHttpClient.internalCache;
 | |
|             this.cache = okHttpClient.cache;
 | |
|             this.socketFactory = okHttpClient.socketFactory;
 | |
|             this.sslSocketFactory = okHttpClient.sslSocketFactory;
 | |
|             this.certificateChainCleaner = okHttpClient.certificateChainCleaner;
 | |
|             this.hostnameVerifier = okHttpClient.hostnameVerifier;
 | |
|             this.certificatePinner = okHttpClient.certificatePinner;
 | |
|             this.proxyAuthenticator = okHttpClient.proxyAuthenticator;
 | |
|             this.authenticator = okHttpClient.authenticator;
 | |
|             this.connectionPool = okHttpClient.connectionPool;
 | |
|             this.dns = okHttpClient.dns;
 | |
|             this.followSslRedirects = okHttpClient.followSslRedirects;
 | |
|             this.followRedirects = okHttpClient.followRedirects;
 | |
|             this.retryOnConnectionFailure = okHttpClient.retryOnConnectionFailure;
 | |
|             this.connectTimeout = okHttpClient.connectTimeout;
 | |
|             this.readTimeout = okHttpClient.readTimeout;
 | |
|             this.writeTimeout = okHttpClient.writeTimeout;
 | |
|             this.pingInterval = okHttpClient.pingInterval;
 | |
|         }
 | |
|     }
 | |
| }
 |