make it compile

This commit is contained in:
Aria Moradi
2021-08-23 04:02:55 +04:30
parent 3272b9dec5
commit 5ca42bf9b6
4 changed files with 8 additions and 5 deletions
@@ -17,4 +17,4 @@ class PersistentCookieJar(context: Context) : CookieJar {
override fun loadForRequest(url: HttpUrl): List<Cookie> {
return store.get(url)
}
}
}
@@ -76,5 +76,4 @@ class PersistentCookieStore(context: Context) {
}
private fun Cookie.hasExpired() = System.currentTimeMillis() >= expiresAt
}
}
@@ -4,6 +4,7 @@ import com.gargoylesoftware.htmlunit.BrowserVersion
import com.gargoylesoftware.htmlunit.WebClient
import com.gargoylesoftware.htmlunit.html.HtmlPage
import eu.kanade.tachiyomi.network.NetworkHelper
import mu.KotlinLogging
import okhttp3.Cookie
import okhttp3.HttpUrl
import okhttp3.Interceptor
@@ -14,6 +15,8 @@ import java.io.IOException
// from TachiWeb-Server
class CloudflareInterceptor : Interceptor {
private val logger = KotlinLogging.logger {}
private val network: NetworkHelper by injectLazy()
private val `serverCheck` = arrayOf("cloudflare-nginx", "cloudflare")
@@ -24,6 +27,7 @@ class CloudflareInterceptor : Interceptor {
// Check if Cloudflare anti-bot is on
if (response.code == 503 && response.header("Server") in serverCheck) {
logger.debug { "CloudflareInterceptor is kicking in..." }
return try {
chain.proceed(resolveChallenge(response))
} catch (e: Exception) {
@@ -92,4 +96,4 @@ class CloudflareInterceptor : Interceptor {
.header("Cookie", newCookies.map { it.toString() }.joinToString("; "))
.build()
}
}
}
@@ -75,7 +75,7 @@ abstract class HttpSource : CatalogueSource {
* Headers builder for requests. Implementations can override this method for custom headers.
*/
protected open fun headersBuilder() = Headers.Builder().apply {
add("User-Agent", DEFAULT_USERAGENT)
add("User-Agent", DEFAULT_USER_AGENT)
}
/**