use of com.risenb.expand.network.cookie.ClearableCookieJar in project AndroidFrame by tongxiaoyun.
the class m method initNetWorkWithCookie.
/**
* 初始化网络控制器
*/
public m initNetWorkWithCookie(Context context) {
// 持久化存储cookie
ClearableCookieJar cookieJar = new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(context));
// log拦截器
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
// 自定义OkHttp
OkHttpClient okHttpClient = new OkHttpClient.Builder().connectTimeout(10000L, TimeUnit.MILLISECONDS).readTimeout(10000L, TimeUnit.MILLISECONDS).cookieJar(// 设置开启cookie
cookieJar).addInterceptor(// 设置开启log
logging).build();
netUtils = new MyOkHttp(okHttpClient);
return instance;
}
Aggregations