|
|
@ -1,5 +1,6 @@ |
|
|
|
package io.legado.app.help.http |
|
|
|
package io.legado.app.help.http |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import io.legado.app.constant.AppConst |
|
|
|
import io.legado.app.help.config.AppConfig |
|
|
|
import io.legado.app.help.config.AppConfig |
|
|
|
import io.legado.app.help.http.cronet.CronetInterceptor |
|
|
|
import io.legado.app.help.http.cronet.CronetInterceptor |
|
|
|
import io.legado.app.help.http.cronet.CronetLoader |
|
|
|
import io.legado.app.help.http.cronet.CronetLoader |
|
|
@ -36,12 +37,14 @@ val okHttpClient: OkHttpClient by lazy { |
|
|
|
.followSslRedirects(true) |
|
|
|
.followSslRedirects(true) |
|
|
|
.addInterceptor(Interceptor { chain -> |
|
|
|
.addInterceptor(Interceptor { chain -> |
|
|
|
val request = chain.request() |
|
|
|
val request = chain.request() |
|
|
|
.newBuilder() |
|
|
|
val builder = request.newBuilder() |
|
|
|
.addHeader("Keep-Alive", "300") |
|
|
|
if (request.header(AppConst.UA_NAME) == null) { |
|
|
|
.addHeader("Connection", "Keep-Alive") |
|
|
|
builder.addHeader(AppConst.UA_NAME, AppConfig.userAgent) |
|
|
|
.addHeader("Cache-Control", "no-cache") |
|
|
|
} |
|
|
|
.build() |
|
|
|
builder.addHeader("Keep-Alive", "300") |
|
|
|
chain.proceed(request) |
|
|
|
builder.addHeader("Connection", "Keep-Alive") |
|
|
|
|
|
|
|
builder.addHeader("Cache-Control", "no-cache") |
|
|
|
|
|
|
|
chain.proceed(builder.build()) |
|
|
|
}) |
|
|
|
}) |
|
|
|
if (!AppConfig.isGooglePlay && AppConfig.isCronet && CronetLoader.install()) { |
|
|
|
if (!AppConfig.isGooglePlay && AppConfig.isCronet && CronetLoader.install()) { |
|
|
|
builder.addInterceptor(CronetInterceptor(null)) |
|
|
|
builder.addInterceptor(CronetInterceptor(null)) |
|
|
|