|
|
|
@ -2,6 +2,7 @@ package org.koitharu.kotatsu.core.network
|
|
|
|
|
|
|
|
|
|
|
|
import okhttp3.Interceptor
|
|
|
|
import okhttp3.Interceptor
|
|
|
|
import okhttp3.Response
|
|
|
|
import okhttp3.Response
|
|
|
|
|
|
|
|
import okio.IOException
|
|
|
|
import org.koitharu.kotatsu.core.network.CommonHeaders.CONTENT_ENCODING
|
|
|
|
import org.koitharu.kotatsu.core.network.CommonHeaders.CONTENT_ENCODING
|
|
|
|
|
|
|
|
|
|
|
|
class GZipInterceptor : Interceptor {
|
|
|
|
class GZipInterceptor : Interceptor {
|
|
|
|
@ -9,6 +10,10 @@ class GZipInterceptor : Interceptor {
|
|
|
|
override fun intercept(chain: Interceptor.Chain): Response {
|
|
|
|
override fun intercept(chain: Interceptor.Chain): Response {
|
|
|
|
val newRequest = chain.request().newBuilder()
|
|
|
|
val newRequest = chain.request().newBuilder()
|
|
|
|
newRequest.addHeader(CONTENT_ENCODING, "gzip")
|
|
|
|
newRequest.addHeader(CONTENT_ENCODING, "gzip")
|
|
|
|
return chain.proceed(newRequest.build())
|
|
|
|
return try {
|
|
|
|
|
|
|
|
chain.proceed(newRequest.build())
|
|
|
|
|
|
|
|
} catch (e: NullPointerException) {
|
|
|
|
|
|
|
|
throw IOException(e)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|