Search in sources :

Example 1 with PersistentCookieStore

use of com.zhy.http.okhttp.cookie.store.PersistentCookieStore in project GzuClassSchedule by mnnyang.

the class app method initOkHttp.

private void initOkHttp() {
    OkHttpClient okHttpClient = new OkHttpClient.Builder().followSslRedirects(false).cookieJar(// 为OkHttp设置自动携带Cookie的功能
    new LocalCookieJar()).addInterceptor(new LoggerInterceptor("TAG")).cookieJar(// 要在内存Cookie前
    new CookieJarImpl(new PersistentCookieStore(getBaseContext()))).cookieJar(// 内存Cookie
    new CookieJarImpl(new MemoryCookieStore())).build();
    OkHttpUtils.initClient(okHttpClient);
}
Also used : PersistentCookieStore(com.zhy.http.okhttp.cookie.store.PersistentCookieStore) OkHttpClient(okhttp3.OkHttpClient) LoggerInterceptor(com.zhy.http.okhttp.log.LoggerInterceptor) CookieJarImpl(com.zhy.http.okhttp.cookie.CookieJarImpl) MemoryCookieStore(com.zhy.http.okhttp.cookie.store.MemoryCookieStore)

Aggregations

CookieJarImpl (com.zhy.http.okhttp.cookie.CookieJarImpl)1 MemoryCookieStore (com.zhy.http.okhttp.cookie.store.MemoryCookieStore)1 PersistentCookieStore (com.zhy.http.okhttp.cookie.store.PersistentCookieStore)1 LoggerInterceptor (com.zhy.http.okhttp.log.LoggerInterceptor)1 OkHttpClient (okhttp3.OkHttpClient)1