OKHttp: rise maxRequestsPerHost to 64 (instead of default 5)

This commit is contained in:
ganfra 2022-06-02 15:38:19 +02:00
parent 797dc9ccbb
commit 47bc597b99

View file

@ -21,6 +21,7 @@ import com.squareup.moshi.Moshi
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
import okhttp3.ConnectionSpec import okhttp3.ConnectionSpec
import okhttp3.Dispatcher
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Protocol import okhttp3.Protocol
import okhttp3.logging.HttpLoggingInterceptor import okhttp3.logging.HttpLoggingInterceptor
@ -70,7 +71,9 @@ internal object NetworkModule {
curlLoggingInterceptor: CurlLoggingInterceptor, curlLoggingInterceptor: CurlLoggingInterceptor,
apiInterceptor: ApiInterceptor): OkHttpClient { apiInterceptor: ApiInterceptor): OkHttpClient {
val spec = ConnectionSpec.Builder(matrixConfiguration.connectionSpec).build() val spec = ConnectionSpec.Builder(matrixConfiguration.connectionSpec).build()
val dispatcher = Dispatcher().apply {
maxRequestsPerHost = 64
}
return OkHttpClient.Builder() return OkHttpClient.Builder()
// workaround for #4669 // workaround for #4669
.protocols(listOf(Protocol.HTTP_1_1)) .protocols(listOf(Protocol.HTTP_1_1))
@ -94,6 +97,7 @@ internal object NetworkModule {
proxy(it) proxy(it)
} }
} }
.dispatcher(dispatcher)
.connectionSpecs(Collections.singletonList(spec)) .connectionSpecs(Collections.singletonList(spec))
.build() .build()
} }