From 17f7e5723d3e93565a89e3e09615a21e2b00509e Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 30 Nov 2021 14:56:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/help/http/cronet/CronetInterceptor.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/http/cronet/CronetInterceptor.kt b/app/src/main/java/io/legado/app/help/http/cronet/CronetInterceptor.kt index f0648aacd..e1b2372b4 100644 --- a/app/src/main/java/io/legado/app/help/http/cronet/CronetInterceptor.kt +++ b/app/src/main/java/io/legado/app/help/http/cronet/CronetInterceptor.kt @@ -2,11 +2,10 @@ package io.legado.app.help.http.cronet import io.legado.app.help.http.CookieStore import okhttp3.* -import java.io.IOException +import timber.log.Timber class CronetInterceptor(private val cookieJar: CookieJar?) : Interceptor { - @Throws(IOException::class) override fun intercept(chain: Interceptor.Chain): Response { val original: Request = chain.request() //Cronet未初始化 @@ -29,13 +28,18 @@ class CronetInterceptor(private val cookieJar: CookieJar?) : Interceptor { response } ?: chain.proceed(original) } catch (e: Exception) { + //不能抛出错误,抛出错误会导致应用崩溃 //遇到Cronet处理有问题时的情况,如证书过期等等,回退到okhttp处理 + if (!e.message.toString().contains("ERR_CERT_", true) + && !e.message.toString().contains("ERR_SSL_", true) + ) { + Timber.e(e) + } chain.proceed(original) } } - @Throws(IOException::class) private fun proceedWithCronet(request: Request, call: Call): Response? { val callback = CronetRequestCallback(request, call) buildRequest(request, callback)?.let {