pull/977/head
gedoor 4 years ago
parent dd4192b3d6
commit af769120da
  1. 6
      app/src/main/java/io/legado/app/help/http/OkHttpUtils.kt
  2. 8
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -82,6 +82,12 @@ fun ResponseBody.text(encode: String? = null): String {
return String(responseBytes, Charset.forName(charsetName))
}
fun Request.Builder.addHeaders(headers: Map<String, String>) {
headers.forEach {
addHeader(it.key, it.value)
}
}
fun Request.Builder.get(url: String, queryMap: Map<String, String>, encoded: Boolean = false) {
val httpBuilder = url.toHttpUrl().newBuilder()
queryMap.forEach {

@ -308,9 +308,7 @@ class AnalyzeUrl(
}
return getProxyClient(proxy).newCallStrResponse(retry) {
removeHeader(UA_NAME)
headerMap.forEach {
addHeader(it.key, it.value)
}
addHeaders(headerMap)
when (method) {
RequestMethod.POST -> {
url(url)
@ -330,9 +328,7 @@ class AnalyzeUrl(
@Suppress("BlockingMethodInNonBlockingContext")
return getProxyClient(proxy).newCall(retry) {
removeHeader(UA_NAME)
headerMap.forEach {
addHeader(it.key, it.value)
}
addHeaders(headerMap)
when (method) {
RequestMethod.POST -> {
url(url)

Loading…
Cancel
Save