Search in sources :

Example 1 with HeaderInterceptor

use of com.justwayward.reader.api.support.HeaderInterceptor in project BookReader by JustWayward.

the class BookApiModule method provideOkHttpClient.

@Provides
public OkHttpClient provideOkHttpClient() {
    LoggingInterceptor logging = new LoggingInterceptor(new Logger());
    logging.setLevel(LoggingInterceptor.Level.BODY);
    OkHttpClient.Builder builder = new OkHttpClient.Builder().connectTimeout(10, TimeUnit.SECONDS).connectTimeout(20 * 1000, TimeUnit.MILLISECONDS).readTimeout(20 * 1000, TimeUnit.MILLISECONDS).retryOnConnectionFailure(// 失败重发
    true).addInterceptor(new HeaderInterceptor()).addInterceptor(logging);
    return builder.build();
}
Also used : LoggingInterceptor(com.justwayward.reader.api.support.LoggingInterceptor) OkHttpClient(okhttp3.OkHttpClient) HeaderInterceptor(com.justwayward.reader.api.support.HeaderInterceptor) Logger(com.justwayward.reader.api.support.Logger) Provides(dagger.Provides)

Aggregations

HeaderInterceptor (com.justwayward.reader.api.support.HeaderInterceptor)1 Logger (com.justwayward.reader.api.support.Logger)1 LoggingInterceptor (com.justwayward.reader.api.support.LoggingInterceptor)1 Provides (dagger.Provides)1 OkHttpClient (okhttp3.OkHttpClient)1