直接创建一个空的GlideHeaders,默认的确实自带ua

pull/1859/head
kunfei 3 years ago
parent 0302b0aa57
commit 1d474c716c
  1. 11
      app/src/main/java/io/legado/app/help/glide/GlideHeaders.kt
  2. 10
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -0,0 +1,11 @@
package io.legado.app.help.glide
import com.bumptech.glide.load.model.Headers
class GlideHeaders(private val headers: MutableMap<String, String>) : Headers {
override fun getHeaders(): MutableMap<String, String> {
return headers
}
}

@ -4,7 +4,6 @@ import android.annotation.SuppressLint
import android.util.Base64 import android.util.Base64
import androidx.annotation.Keep import androidx.annotation.Keep
import com.bumptech.glide.load.model.GlideUrl import com.bumptech.glide.load.model.GlideUrl
import com.bumptech.glide.load.model.LazyHeaders
import com.script.SimpleBindings import com.script.SimpleBindings
import io.legado.app.constant.AppConst.SCRIPT_ENGINE import io.legado.app.constant.AppConst.SCRIPT_ENGINE
import io.legado.app.constant.AppConst.UA_NAME import io.legado.app.constant.AppConst.UA_NAME
@ -17,6 +16,7 @@ import io.legado.app.exception.ConcurrentException
import io.legado.app.help.CacheManager import io.legado.app.help.CacheManager
import io.legado.app.help.JsExtensions import io.legado.app.help.JsExtensions
import io.legado.app.help.config.AppConfig import io.legado.app.help.config.AppConfig
import io.legado.app.help.glide.GlideHeaders
import io.legado.app.help.http.* import io.legado.app.help.http.*
import io.legado.app.utils.* import io.legado.app.utils.*
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
@ -540,13 +540,7 @@ class AnalyzeUrl(
*/ */
fun getGlideUrl(): GlideUrl { fun getGlideUrl(): GlideUrl {
setCookie(source?.getKey()) setCookie(source?.getKey())
val headers = LazyHeaders.Builder() return GlideUrl(url, GlideHeaders(headerMap))
//删除glide默认ua
headers.setHeader(UA_NAME, null as String?)
headerMap.forEach { (key, value) ->
headers.addHeader(key, value)
}
return GlideUrl(url, headers.build())
} }
fun getUserAgent(): String { fun getUserAgent(): String {

Loading…
Cancel
Save