From 963cf4c99692726a05d1c8e1e2f8abdac9864056 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 4 Jul 2020 10:33:31 -0400 Subject: [PATCH] Fallback to default UA string for all network requests --- .../java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt | 2 +- app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt b/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt index 5b3d47064..57a86e464 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt @@ -87,7 +87,7 @@ class CloudflareInterceptor(private val context: Context) : Interceptor { webView = webview webview.settings.javaScriptEnabled = true - // Avoid set empty User-Agent, Chromium WebView will reset to default if empty + // Avoid sending empty User-Agent, Chromium WebView will reset to default if empty webview.settings.userAgentString = request.header("User-Agent") ?: HttpSource.DEFAULT_USERAGENT diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt index 8cb5d3906..aeb7ce5cd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt @@ -29,6 +29,7 @@ class NetworkHelper(context: Context) { .cache(Cache(cacheDir, cacheSize)) .connectTimeout(30, TimeUnit.SECONDS) .readTimeout(30, TimeUnit.SECONDS) + .addInterceptor(UserAgentInterceptor()) if (BuildConfig.DEBUG) { val httpLoggingInterceptor = HttpLoggingInterceptor().apply { @@ -63,7 +64,6 @@ class NetworkHelper(context: Context) { val cloudflareClient by lazy { client.newBuilder() - .addInterceptor(UserAgentInterceptor()) .addInterceptor(CloudflareInterceptor(context)) .build() }