Use regular minified extensions JSON instead of explicitly handling gzip encoding

Turns out GitHub *does* do gzip encoding by default, it just doesn't show up in the header logs for some reason...
This commit is contained in:
arkon 2020-11-29 16:01:16 -05:00
parent 3133a63cf8
commit 6664dfb048

View File

@ -15,30 +15,18 @@ import uy.kohesive.injekt.injectLazy
interface ExtensionGithubService { interface ExtensionGithubService {
companion object { companion object {
private val client by lazy {
val network: NetworkHelper by injectLazy()
network.client.newBuilder()
.addNetworkInterceptor { chain ->
val originalResponse = chain.proceed(chain.request())
originalResponse.newBuilder()
.header("Content-Encoding", "gzip")
.header("Content-Type", "application/json")
.build()
}
.build()
}
fun create(): ExtensionGithubService { fun create(): ExtensionGithubService {
val network: NetworkHelper by injectLazy()
val adapter = Retrofit.Builder() val adapter = Retrofit.Builder()
.baseUrl(ExtensionGithubApi.BASE_URL) .baseUrl(ExtensionGithubApi.BASE_URL)
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) .addConverterFactory(Json.asConverterFactory("application/json".toMediaType()))
.client(client) .client(network.client)
.build() .build()
return adapter.create(ExtensionGithubService::class.java) return adapter.create(ExtensionGithubService::class.java)
} }
} }
@GET("${ExtensionGithubApi.REPO_URL_PREFIX}index.json.gz") @GET("${ExtensionGithubApi.REPO_URL_PREFIX}index.min.json")
suspend fun getRepo(): JsonArray suspend fun getRepo(): JsonArray
} }