mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -7,9 +7,10 @@ import okhttp3.internal.http.promisesBody
|
||||
import okio.buffer
|
||||
import okio.source
|
||||
import java.util.zip.GZIPInputStream
|
||||
import java.util.zip.Inflater
|
||||
import java.util.zip.InflaterInputStream
|
||||
|
||||
object DecompressInterceptor: Interceptor {
|
||||
object DecompressInterceptor : Interceptor {
|
||||
override fun intercept(chain: Interceptor.Chain): Response {
|
||||
val request = chain.request()
|
||||
val requestBuilder = request.newBuilder()
|
||||
@@ -30,7 +31,7 @@ object DecompressInterceptor: Interceptor {
|
||||
val encoding = response.header("Content-Encoding")?.lowercase()
|
||||
val source = when (encoding) {
|
||||
"gzip" -> GZIPInputStream(body.byteStream()).source().buffer()
|
||||
"deflate" -> InflaterInputStream(body.byteStream()).source().buffer()
|
||||
"deflate" -> InflaterInputStream(body.byteStream(), Inflater(true)).source().buffer()
|
||||
else -> return response
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user