我基本上想要使用以下两个功能
//记录
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(logging)
.build();
//超时
OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(300, TimeUnit.SECONDS)
.readTimeout(300,TimeUnit.SECONDS).build();
答案 0 :(得分:1)
只需使用带有拦截器和超时的构建器。
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(logging)
.connectTimeout(300, TimeUnit.SECONDS)
.readTimeout(300,TimeUnit.SECONDS)
.build();
答案 1 :(得分:1)
只需将其添加到那里:
Objective C