Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
821938089 committed Sep 27, 2024
1 parent ff37151 commit bb5876e
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
}

Expand Down

0 comments on commit bb5876e

Please sign in to comment.