public CookieStore getCookieStore() {
   final CookieJar cookieJar = mOkHttpClient.cookieJar();
   if (cookieJar == null) {
     new IllegalArgumentException(
         "you should invoked okHttpClientBuilder.cookieJar() to set a cookieJar.");
   }
   if (cookieJar instanceof HasCookieStore) {
     return ((HasCookieStore) cookieJar).getCookieStore();
   } else {
     return null;
   }
 }
示例#2
0
  private Response getResponseWithInterceptorChain() throws IOException {
    // Build a full stack of interceptors.
    List<Interceptor> interceptors = new ArrayList<>();
    interceptors.addAll(client.interceptors());
    interceptors.add(retryAndFollowUpInterceptor);
    interceptors.add(new BridgeInterceptor(client.cookieJar()));
    interceptors.add(new CacheInterceptor(client.internalCache()));
    interceptors.add(new ConnectInterceptor(client));
    if (!retryAndFollowUpInterceptor.isForWebSocket()) {
      interceptors.addAll(client.networkInterceptors());
    }
    interceptors.add(new CallServerInterceptor(retryAndFollowUpInterceptor.isForWebSocket()));

    Interceptor.Chain chain =
        new RealInterceptorChain(interceptors, null, null, null, 0, originalRequest);
    return chain.proceed(originalRequest);
  }