diff --git a/app/src/gms/kotlin/com/hippo/ehviewer/cronet/CronetKt.kt b/app/src/gms/kotlin/com/hippo/ehviewer/cronet/CronetKt.kt index 5b59a5123..eb0da95c9 100644 --- a/app/src/gms/kotlin/com/hippo/ehviewer/cronet/CronetKt.kt +++ b/app/src/gms/kotlin/com/hippo/ehviewer/cronet/CronetKt.kt @@ -13,6 +13,7 @@ import kotlin.coroutines.resumeWithException import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch import kotlinx.coroutines.suspendCancellableCoroutine +import okio.Path.Companion.toOkioPath import org.chromium.net.CronetEngine import org.chromium.net.CronetException import org.chromium.net.UrlRequest @@ -22,6 +23,11 @@ import splitties.init.appCtx val cronetHttpClient: CronetEngine = CronetEngine.Builder(appCtx).apply { enableBrotli(true) setUserAgent(Settings.userAgent) + + // Cache Quic hint only since the real cache mechanism should on Ktor layer + val cache = (appCtx.cacheDir.toOkioPath() / "http_cache").toFile().apply { mkdirs() } + setStoragePath(cache.absolutePath) + enableHttpCache(CronetEngine.Builder.HTTP_CACHE_DISK_NO_HTTP, 1024) }.build() class CronetRequest { diff --git a/app/src/oss/kotlin/com/hippo/ehviewer/cronet/CronetKt.kt b/app/src/oss/kotlin/com/hippo/ehviewer/cronet/CronetKt.kt index ed826c527..004da0e3f 100644 --- a/app/src/oss/kotlin/com/hippo/ehviewer/cronet/CronetKt.kt +++ b/app/src/oss/kotlin/com/hippo/ehviewer/cronet/CronetKt.kt @@ -19,11 +19,17 @@ import kotlin.coroutines.resumeWithException import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch import kotlinx.coroutines.suspendCancellableCoroutine +import okio.Path.Companion.toOkioPath import splitties.init.appCtx val cronetHttpClient: HttpEngine = HttpEngine.Builder(appCtx).apply { setEnableBrotli(true) setUserAgent(CHROME_USER_AGENT) + + // Cache Quic hint only since the real cache mechanism should on Ktor layer + val cache = (appCtx.cacheDir.toOkioPath() / "http_cache").toFile().apply { mkdirs() } + setStoragePath(cache.absolutePath) + setEnableHttpCache(HttpEngine.Builder.HTTP_CACHE_DISK_NO_HTTP, 1024) }.build() class CronetRequest {