url参数添加重试次数retry

pull/977/head
gedoor 4 years ago
parent a45b5844ab
commit f96c0a217c
  1. 9
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -55,6 +55,7 @@ class AnalyzeUrl(
private var charset: String? = null
private var method = RequestMethod.GET
private var proxy: String? = null
private var retry: Int = 0
init {
baseUrl = baseUrl.split(splitUrlRegex, 1)[0]
@ -197,6 +198,7 @@ class AnalyzeUrl(
option.js?.let {
evalJS(it)
}
retry = option.retry
}
}
headerMap[UA_NAME] ?: let {
@ -304,7 +306,7 @@ class AnalyzeUrl(
params.tag = tag
return getWebViewSrc(params)
}
return getProxyClient(proxy).newCallStrResponse {
return getProxyClient(proxy).newCallStrResponse(retry) {
removeHeader(UA_NAME)
headerMap.forEach {
addHeader(it.key, it.value)
@ -326,7 +328,7 @@ class AnalyzeUrl(
suspend fun getByteArray(tag: String? = null): ByteArray {
setCookie(tag)
@Suppress("BlockingMethodInNonBlockingContext")
return getProxyClient(proxy).newCall {
return getProxyClient(proxy).newCall(retry) {
removeHeader(UA_NAME)
headerMap.forEach {
addHeader(it.key, it.value)
@ -375,7 +377,8 @@ class AnalyzeUrl(
val headers: Any?,
val body: Any?,
val type: String?,
val js: String?
val js: String?,
val retry: Int = 0
)
}

Loading…
Cancel
Save