GZip compression for networking

pull/163/head
Koitharu 4 years ago
parent f3181cc0f1
commit 3963099053
No known key found for this signature in database
GPG Key ID: 8E861F8CE6E7CE27

@ -5,7 +5,7 @@ charset = utf-8
end_of_line = lf end_of_line = lf
indent_size = 4 indent_size = 4
indent_style = tab indent_style = tab
insert_final_newline = false insert_final_newline = true
max_line_length = 120 max_line_length = 120
tab_width = 4 tab_width = 4
# noinspection EditorConfigKeyCorrectness # noinspection EditorConfigKeyCorrectness

@ -0,0 +1,14 @@
package org.koitharu.kotatsu.core.network
import okhttp3.Interceptor
import okhttp3.Response
import org.jsoup.helper.HttpConnection.CONTENT_ENCODING
class GZipInterceptor : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val newRequest = chain.request().newBuilder()
newRequest.addHeader(CONTENT_ENCODING, "gzip")
return chain.proceed(newRequest.build())
}
}

@ -21,9 +21,10 @@ val networkModule
cookieJar(get()) cookieJar(get())
dns(DoHManager(cache, get())) dns(DoHManager(cache, get()))
cache(cache) cache(cache)
addInterceptor(GZipInterceptor())
addInterceptor(UserAgentInterceptor()) addInterceptor(UserAgentInterceptor())
addInterceptor(CloudFlareInterceptor()) addInterceptor(CloudFlareInterceptor())
}.build() }.build()
} }
single<MangaLoaderContext> { MangaLoaderContextImpl(get(), get(), get()) } single<MangaLoaderContext> { MangaLoaderContextImpl(get(), get(), get()) }
} }

Loading…
Cancel
Save