From 846ce02d93118570dce1da46182c33f69cbc1563 Mon Sep 17 00:00:00 2001 From: ag2s20150909 Date: Mon, 19 Jul 2021 19:04:55 +0800 Subject: [PATCH] =?UTF-8?q?Cronet:=E4=BF=AE=E5=A4=8Dcronet=E8=AE=BF?= =?UTF-8?q?=E9=97=AE=E6=94=AF=E6=8C=81http3=E7=94=B1=E4=BA=8E=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E5=A4=B4=E7=9A=84keep-alive=E8=80=8C=E5=AF=BC?= =?UTF-8?q?=E8=87=B4400?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/AppConfig.kt | 4 ++-- .../java/io/legado/app/help/http/cronet/CronetHelper.kt | 7 +++++-- app/src/main/res/xml/network_security_config.xml | 7 +++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index d1141276b..97a43f359 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -231,8 +231,8 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { private fun getPrefUserAgent(): String { val ua = appCtx.getPrefString(PreferKey.userAgent) if (ua.isNullOrBlank()) { - return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36" - } + return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" + } return ua } } diff --git a/app/src/main/java/io/legado/app/help/http/cronet/CronetHelper.kt b/app/src/main/java/io/legado/app/help/http/cronet/CronetHelper.kt index 8229f46cd..b6d50f116 100644 --- a/app/src/main/java/io/legado/app/help/http/cronet/CronetHelper.kt +++ b/app/src/main/java/io/legado/app/help/http/cronet/CronetHelper.kt @@ -41,7 +41,11 @@ fun buildRequest(request: Request, callback: UrlRequest.Callback): UrlRequest { } val headers: Headers = request.headers headers.forEachIndexed { index, _ -> - requestBuilder.addHeader(headers.name(index), headers.value(index)) + val name = headers.name(index) + if (!name.equals("Keep-Alive", true)) { + requestBuilder.addHeader(name, headers.value(index)) + } + } val requestBody = request.body @@ -60,6 +64,5 @@ fun buildRequest(request: Request, callback: UrlRequest.Callback): UrlRequest { } return requestBuilder.build() - } diff --git a/app/src/main/res/xml/network_security_config.xml b/app/src/main/res/xml/network_security_config.xml index 2c950a5b6..99b392d5a 100644 --- a/app/src/main/res/xml/network_security_config.xml +++ b/app/src/main/res/xml/network_security_config.xml @@ -3,4 +3,11 @@ + + + + + + + \ No newline at end of file