optimize okhttp

This commit is contained in:
Evan You
2025-03-13 11:45:02 +08:00
parent 35acbacb7e
commit 6cab61efa5
2 changed files with 11 additions and 3 deletions

View File

@@ -15,8 +15,8 @@ android {
applicationId = "com.donut.mixfile"
minSdk = 24
targetSdk = 35
versionCode = 73
versionName = "1.9.1"
versionCode = 74
versionName = "1.9.2"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {

View File

@@ -15,11 +15,19 @@ import io.ktor.serialization.gson.GsonConverter
import io.ktor.serialization.gson.gson
import io.ktor.utils.io.ByteWriteChannel
import io.ktor.utils.io.jvm.javaio.toOutputStream
import okhttp3.Dispatcher
import java.io.InputStream
var UPLOAD_RETRY_TIMES by cachedMutableOf(3, "UPLOAD_RETRY_TIMES")
val uploadClient = HttpClient(OkHttp).config {
val uploadClient = HttpClient(OkHttp) {
engine {
config {
val dispatcher = Dispatcher()
dispatcher.maxRequestsPerHost = 100
dispatcher(dispatcher)
}
}
install(ContentNegotiation) {
gson()
register(ContentType.Any, GsonConverter(GsonBuilder().create()))