mirror of
https://github.com/revanced/revanced-manager-compose-old.git
synced 2025-04-29 22:14:28 +02:00
feat: HTTP/3
This commit is contained in:
parent
8f41b2e284
commit
2d1b80c70f
@ -135,4 +135,6 @@ dependencies {
|
||||
implementation("com.google.guava:guava:31.0.1-android")
|
||||
implementation("androidx.concurrent:concurrent-futures:1.1.0")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-guava:1.6.4")
|
||||
|
||||
implementation("com.github.niusounds:cronet-engine:0.1.0")
|
||||
}
|
||||
|
@ -1,29 +1,26 @@
|
||||
package app.revanced.manager.di
|
||||
|
||||
import android.content.Context
|
||||
import com.niusounds.ktor.client.engine.cronet.Cronet
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.engine.okhttp.*
|
||||
import io.ktor.client.plugins.*
|
||||
import io.ktor.client.plugins.cache.*
|
||||
import io.ktor.client.plugins.contentnegotiation.*
|
||||
import io.ktor.serialization.kotlinx.json.*
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.Dns
|
||||
import org.koin.core.module.dsl.singleOf
|
||||
import org.koin.android.ext.koin.androidContext
|
||||
import org.koin.dsl.module
|
||||
import java.net.Inet4Address
|
||||
import java.net.InetAddress
|
||||
|
||||
val httpModule = module {
|
||||
fun provideHttpClient() = HttpClient(OkHttp) {
|
||||
engine {
|
||||
config {
|
||||
dns(object : Dns {
|
||||
override fun lookup(hostname: String): List<InetAddress> {
|
||||
val addresses = Dns.SYSTEM.lookup(hostname)
|
||||
return addresses.filterIsInstance<Inet4Address>()
|
||||
}
|
||||
})
|
||||
fun provideHttpClient(appContext: Context) = HttpClient(
|
||||
engine = Cronet.create {
|
||||
context = appContext
|
||||
config = {
|
||||
enableBrotli(true)
|
||||
enableQuic(true)
|
||||
}
|
||||
}
|
||||
) {
|
||||
BrowserUserAgent()
|
||||
install(ContentNegotiation) {
|
||||
json(Json {
|
||||
@ -32,7 +29,13 @@ val httpModule = module {
|
||||
ignoreUnknownKeys = true
|
||||
})
|
||||
}
|
||||
install(HttpRequestRetry) {
|
||||
retryOnServerErrors(maxRetries = 5)
|
||||
}
|
||||
install(HttpCache)
|
||||
}
|
||||
|
||||
singleOf(::provideHttpClient)
|
||||
single {
|
||||
provideHttpClient(androidContext())
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user