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

Loading…
Cancel
Save