Merge pull request #1857 from Xwite/master

Glide 默认ua添加bug
pull/1859/head
kunfei 3 years ago committed by GitHub
commit 0302b0aa57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/src/main/java/io/legado/app/help/glide/OkHttpStreamFetcher.kt
  2. 2
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -39,7 +39,6 @@ class OkHttpStreamFetcher(private val url: GlideUrl, private val options: Option
}
val requestBuilder: Request.Builder = Request.Builder().url(url.toStringUrl())
val headerMap = HashMap<String, String>()
headerMap.putAll(url.headers)
options.get(OkHttpModelLoader.sourceOriginOption)?.let { sourceUrl ->
val source = appDb.bookSourceDao.getBookSource(sourceUrl)
?: appDb.rssSourceDao.getByKey(sourceUrl)
@ -47,6 +46,7 @@ class OkHttpStreamFetcher(private val url: GlideUrl, private val options: Option
headerMap.putAll(it)
}
}
headerMap.putAll(url.headers)
requestBuilder.addHeaders(headerMap)
val request: Request = requestBuilder.build()
this.callback = callback

@ -541,6 +541,8 @@ class AnalyzeUrl(
fun getGlideUrl(): GlideUrl {
setCookie(source?.getKey())
val headers = LazyHeaders.Builder()
//删除glide默认ua
headers.setHeader(UA_NAME, null as String?)
headerMap.forEach { (key, value) ->
headers.addHeader(key, value)
}

Loading…
Cancel
Save