mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-03 19:04:39 -05:00
Fix brotli (#818)
This commit is contained in:
@@ -16,6 +16,7 @@ package eu.kanade.tachiyomi.network
|
|||||||
// import uy.kohesive.injekt.injectLazy
|
// import uy.kohesive.injekt.injectLazy
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import eu.kanade.tachiyomi.network.interceptor.CloudflareInterceptor
|
import eu.kanade.tachiyomi.network.interceptor.CloudflareInterceptor
|
||||||
|
import eu.kanade.tachiyomi.network.interceptor.IgnoreGzipInterceptor
|
||||||
import eu.kanade.tachiyomi.network.interceptor.UncaughtExceptionInterceptor
|
import eu.kanade.tachiyomi.network.interceptor.UncaughtExceptionInterceptor
|
||||||
import eu.kanade.tachiyomi.network.interceptor.UserAgentInterceptor
|
import eu.kanade.tachiyomi.network.interceptor.UserAgentInterceptor
|
||||||
import mu.KotlinLogging
|
import mu.KotlinLogging
|
||||||
@@ -61,9 +62,10 @@ class NetworkHelper(context: Context) {
|
|||||||
maxSize = 5L * 1024 * 1024, // 5 MiB
|
maxSize = 5L * 1024 * 1024, // 5 MiB
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.addInterceptor(BrotliInterceptor)
|
|
||||||
.addInterceptor(UncaughtExceptionInterceptor())
|
.addInterceptor(UncaughtExceptionInterceptor())
|
||||||
.addInterceptor(UserAgentInterceptor())
|
.addInterceptor(UserAgentInterceptor())
|
||||||
|
.addNetworkInterceptor(IgnoreGzipInterceptor())
|
||||||
|
.addNetworkInterceptor(BrotliInterceptor)
|
||||||
|
|
||||||
// if (preferences.verboseLogging().get()) {
|
// if (preferences.verboseLogging().get()) {
|
||||||
val httpLoggingInterceptor =
|
val httpLoggingInterceptor =
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package eu.kanade.tachiyomi.network.interceptor
|
||||||
|
|
||||||
|
import okhttp3.Interceptor
|
||||||
|
import okhttp3.Response
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To use [okhttp3.brotli.BrotliInterceptor] as a network interceptor,
|
||||||
|
* add [IgnoreGzipInterceptor] right before it.
|
||||||
|
*
|
||||||
|
* This nullifies the transparent gzip of [okhttp3.internal.http.BridgeInterceptor]
|
||||||
|
* so gzip and Brotli are explicitly handled by the [okhttp3.brotli.BrotliInterceptor].
|
||||||
|
*/
|
||||||
|
class IgnoreGzipInterceptor : Interceptor {
|
||||||
|
override fun intercept(chain: Interceptor.Chain): Response {
|
||||||
|
var request = chain.request()
|
||||||
|
if (request.header("Accept-Encoding") == "gzip") {
|
||||||
|
request = request.newBuilder().removeHeader("Accept-Encoding").build()
|
||||||
|
}
|
||||||
|
return chain.proceed(request)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user