OkHttpClient okHttpClient = new OkHttpClient.Builder() .addInterceptor(new AddHeaderInterceptor()) .addInterceptor(new ReceivedCookiesInterceptor()) .addNetworkInterceptor(logInterceptor) .connectTimeout(20000L, TimeUnit.MILLISECONDS) .readTimeout(10000L, TimeUnit.MILLISECONDS) .cookieJar(persistentCookieJar) .proxySelector(new ProxySelector() { @Override public List<Proxy> select(URI uri) { return Collections.singletonList(Proxy.NO_PROXY); } @Override public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { } }) .build();
来源:CSDN
作者:weixin_34991050
链接:https://blog.csdn.net/weixin_34991050/article/details/103863747