|
|
@ -1,6 +1,7 @@ |
|
|
|
package io.legado.app.help.http.cronet |
|
|
|
package io.legado.app.help.http.cronet |
|
|
|
|
|
|
|
|
|
|
|
import android.util.Log |
|
|
|
import android.util.Log |
|
|
|
|
|
|
|
import io.legado.app.help.AppConfig |
|
|
|
import okhttp3.Headers |
|
|
|
import okhttp3.Headers |
|
|
|
import okhttp3.MediaType |
|
|
|
import okhttp3.MediaType |
|
|
|
import okhttp3.Request |
|
|
|
import okhttp3.Request |
|
|
@ -19,18 +20,21 @@ val executor: Executor by lazy { Executors.newCachedThreadPool() } |
|
|
|
val cronetEngine: ExperimentalCronetEngine by lazy { |
|
|
|
val cronetEngine: ExperimentalCronetEngine by lazy { |
|
|
|
CronetLoader.preDownload() |
|
|
|
CronetLoader.preDownload() |
|
|
|
|
|
|
|
|
|
|
|
val builder = ExperimentalCronetEngine.Builder(appCtx) |
|
|
|
val builder = ExperimentalCronetEngine.Builder(appCtx).apply { |
|
|
|
.setLibraryLoader(CronetLoader)//设置自定义so库加载 |
|
|
|
if (!AppConfig.isGooglePlay) { |
|
|
|
.setStoragePath(appCtx.externalCacheDir?.absolutePath)//设置缓存路径 |
|
|
|
setLibraryLoader(CronetLoader)//设置自定义so库加载 |
|
|
|
.enableHttpCache(HTTP_CACHE_DISK, (1024 * 1024 * 50))//设置缓存模式 |
|
|
|
} |
|
|
|
.enableQuic(true)//设置支持http/3 |
|
|
|
setStoragePath(appCtx.externalCacheDir?.absolutePath)//设置缓存路径 |
|
|
|
.enableHttp2(true) //设置支持http/2 |
|
|
|
enableHttpCache(HTTP_CACHE_DISK, (1024 * 1024 * 50))//设置缓存模式 |
|
|
|
.enablePublicKeyPinningBypassForLocalTrustAnchors(true) |
|
|
|
enableQuic(true)//设置支持http/3 |
|
|
|
//.enableNetworkQualityEstimator(true) |
|
|
|
enableHttp2(true) //设置支持http/2 |
|
|
|
|
|
|
|
enablePublicKeyPinningBypassForLocalTrustAnchors(true) |
|
|
|
|
|
|
|
//enableNetworkQualityEstimator(true) |
|
|
|
|
|
|
|
|
|
|
|
//Brotli压缩 |
|
|
|
//Brotli压缩 |
|
|
|
builder.enableBrotli(true) |
|
|
|
enableBrotli(true) |
|
|
|
//builder.setExperimentalOptions("{\"quic_version\": \"h3-29\"}") |
|
|
|
//setExperimentalOptions("{\"quic_version\": \"h3-29\"}") |
|
|
|
|
|
|
|
} |
|
|
|
val engine = builder.build() |
|
|
|
val engine = builder.build() |
|
|
|
Log.d("Cronet", "Cronet Version:" + engine.versionString) |
|
|
|
Log.d("Cronet", "Cronet Version:" + engine.versionString) |
|
|
|
//这会导致Jsoup的网络请求出现问题,暂时不接管系统URL |
|
|
|
//这会导致Jsoup的网络请求出现问题,暂时不接管系统URL |
|
|
|