From a8721ad7a48df2c3d4654aa5e8128b0b19d2c839 Mon Sep 17 00:00:00 2001 From: aminecmi Date: Wed, 30 Jan 2019 21:10:58 +0100 Subject: [PATCH] Should intercept socket timeout errors. --- .../bou/readerforselfoss/api/selfoss/SelfossApi.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/api/selfoss/SelfossApi.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/api/selfoss/SelfossApi.kt index 7c325e4..5327add 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/api/selfoss/SelfossApi.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/api/selfoss/SelfossApi.kt @@ -12,7 +12,10 @@ import com.burgstaller.okhttp.digest.CachingAuthenticator import com.burgstaller.okhttp.digest.Credentials import com.burgstaller.okhttp.digest.DigestAuthenticator import com.google.gson.GsonBuilder +import okhttp3.Interceptor import okhttp3.OkHttpClient +import okhttp3.Request +import okhttp3.Response import okhttp3.logging.HttpLoggingInterceptor import retrofit2.Call import retrofit2.Retrofit @@ -62,6 +65,17 @@ class SelfossApi( .maybeWithSelfSigned(isWithSelfSignedCert) .authenticator(CachingAuthenticatorDecorator(this, authCache)) .addInterceptor(AuthenticationCacheInterceptor(authCache)) + .addInterceptor(object: Interceptor { + override fun intercept(chain: Interceptor.Chain): Response { + val request: Request = chain.request() + val response: Response = chain.proceed(request) + + if (response.code() == 408) { + return response + } + return response + } + }) } init {