diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/http/ServiceFactory.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/http/ServiceFactory.kt index b1b9cc6f840dd1b3f822d0408e95f6e44cd5e464..ae9366bfd235e4fc438ce84ee7b80cf3a8815800 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/http/ServiceFactory.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/http/ServiceFactory.kt @@ -5,7 +5,6 @@ import de.rki.coronawarnapp.BuildConfig import de.rki.coronawarnapp.CoronaWarnApplication import de.rki.coronawarnapp.exception.http.ServiceFactoryException import de.rki.coronawarnapp.http.config.HTTPVariables -import de.rki.coronawarnapp.http.interceptor.OfflineCacheInterceptor import de.rki.coronawarnapp.http.interceptor.RetryInterceptor import de.rki.coronawarnapp.http.interceptor.WebSecurityVerificationInterceptor import de.rki.coronawarnapp.http.service.DistributionService @@ -47,9 +46,6 @@ class ServiceFactory { HttpLoggingInterceptor().also { if (BuildConfig.DEBUG) it.setLevel(HttpLoggingInterceptor.Level.BODY) }, - OfflineCacheInterceptor( - CoronaWarnApplication.getAppContext() - ), RetryInterceptor(), HttpErrorParser() ) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/http/interceptor/OfflineCacheInterceptor.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/http/interceptor/OfflineCacheInterceptor.kt deleted file mode 100644 index 929e46f7e19c8d4c06f007ceb61b8ed174882e11..0000000000000000000000000000000000000000 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/http/interceptor/OfflineCacheInterceptor.kt +++ /dev/null @@ -1,49 +0,0 @@ -package de.rki.coronawarnapp.http.interceptor - -import android.content.Context -import de.rki.coronawarnapp.util.ConnectivityHelper.isNetworkEnabled -import okhttp3.Interceptor -import okhttp3.Response - -class OfflineCacheInterceptor(private val context: Context) : Interceptor { - companion object { - private const val MAX_AGE = 5 - private const val MAX_STALE_DAYS = 1 - private const val MAX_STALE = 60 * 60 * 24 * MAX_STALE_DAYS - } - - override fun intercept(chain: Interceptor.Chain): Response { - // Get the request from the chain. - var request = chain.request() - /* - * Leveraging the advantage of using Kotlin, - * we initialize the request and change its header depending on whether - * the device is connected to Internet or not. - */ - request = if (isNetworkEnabled(context)) { - /* - * If there is Internet, get the cache that was stored 5 seconds ago. - * If the cache is older than 5 seconds, then discard it, - * and indicate an error in fetching the response. - * The 'max-age' attribute is responsible for this behavior. - */ - request.newBuilder().header( - "Cache-Control", - "public, max-age=$MAX_AGE" - ).build() - } else { - /* - * If there is no Internet, get the cache that was stored 1 days ago. - * If the cache is older than 1 day, then discard it, - * and indicate an error in fetching the response. - * The 'max-stale' attribute is responsible for this behavior. - * The 'only-if-cached' attribute indicates to not retrieve new data; fetch the cache only instead. - */ - request.newBuilder().header( - "Cache-Control", - "public, only-if-cached, max-stale=$MAX_STALE" - ).build() - } - return chain.proceed(request) - } -}