mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-26 02:48:24 +01:00
Handle Cloudflare in default network client and deprecate cloudflareClient
This commit is contained in:
parent
a629db2884
commit
22e8050fff
@ -44,6 +44,8 @@ class NetworkHelper(
|
|||||||
builder.addNetworkInterceptor(httpLoggingInterceptor)
|
builder.addNetworkInterceptor(httpLoggingInterceptor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
builder.addInterceptor(cloudflareInterceptor)
|
||||||
|
|
||||||
when (preferences.dohProvider().get()) {
|
when (preferences.dohProvider().get()) {
|
||||||
PREF_DOH_CLOUDFLARE -> builder.dohCloudflare()
|
PREF_DOH_CLOUDFLARE -> builder.dohCloudflare()
|
||||||
PREF_DOH_GOOGLE -> builder.dohGoogle()
|
PREF_DOH_GOOGLE -> builder.dohGoogle()
|
||||||
@ -64,12 +66,12 @@ class NetworkHelper(
|
|||||||
|
|
||||||
val client by lazy { baseClientBuilder.cache(Cache(cacheDir, cacheSize)).build() }
|
val client by lazy { baseClientBuilder.cache(Cache(cacheDir, cacheSize)).build() }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Since extension-lib 1.5
|
||||||
|
*/
|
||||||
|
@Deprecated("The regular client handles Cloudflare by default")
|
||||||
@Suppress("UNUSED")
|
@Suppress("UNUSED")
|
||||||
val cloudflareClient by lazy {
|
val cloudflareClient = client
|
||||||
client.newBuilder()
|
|
||||||
.addInterceptor(cloudflareInterceptor)
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun defaultUserAgentProvider() = preferences.defaultUserAgent().get().trim()
|
fun defaultUserAgentProvider() = preferences.defaultUserAgent().get().trim()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user