Skip to content

Commit

Permalink
WebViewResolver: added timeout (recloudstream#941)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sofie99 authored Feb 19, 2024
1 parent e007714 commit 93d81ea
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,37 @@ import java.net.URI
* @param useOkhttp will try to use the okhttp client as much as possible, but this might cause some requests to fail. Disable for cloudflare.
* @param script pass custom js to execute
* @param scriptCallback will be called with the result from custom js
* @param timeout close webview after timeout
* */
class WebViewResolver(
val interceptUrl: Regex,
val additionalUrls: List<Regex> = emptyList(),
val userAgent: String? = USER_AGENT,
val useOkhttp: Boolean = true,
val script: String? = null,
val scriptCallback: ((String) -> Unit)? = null
val scriptCallback: ((String) -> Unit)? = null,
val timeout: Long = DEFAULT_TIMEOUT
) :
Interceptor {

constructor(
interceptUrl: Regex,
additionalUrls: List<Regex> = emptyList(),
userAgent: String? = USER_AGENT,
useOkhttp: Boolean = true,
script: String? = null,
scriptCallback: ((String) -> Unit)? = null,
) : this(interceptUrl, additionalUrls, userAgent, useOkhttp, script, scriptCallback, DEFAULT_TIMEOUT)

constructor(
interceptUrl: Regex,
additionalUrls: List<Regex> = emptyList(),
userAgent: String? = USER_AGENT,
useOkhttp: Boolean = true
) : this(interceptUrl, additionalUrls, userAgent, useOkhttp, null, null)
) : this(interceptUrl, additionalUrls, userAgent, useOkhttp, null, null, DEFAULT_TIMEOUT)

companion object {
private const val DEFAULT_TIMEOUT = 60_000L
var webViewUserAgent: String? = null

@JvmName("getWebViewUserAgent1")
Expand Down Expand Up @@ -262,7 +274,7 @@ class WebViewResolver(

var loop = 0
// Timeouts after this amount, 60s
val totalTime = 60000L
val totalTime = timeout

val delayTime = 100L

Expand Down

0 comments on commit 93d81ea

Please sign in to comment.