Improve Http Client Configuration (#786)

* Improve Http Client Configuration

* Lint
This commit is contained in:
Mitchell Syer
2023-12-08 19:16:38 -05:00
committed by GitHub
parent a2d3fa6e1d
commit 9b27d7ee23
5 changed files with 71 additions and 11 deletions

View File

@@ -14,6 +14,7 @@ import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.model.UpdateStrategy
import eu.kanade.tachiyomi.source.online.HttpSource
import mu.KotlinLogging
import okhttp3.CacheControl
import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.SortOrder
import org.jetbrains.exposed.sql.and
@@ -280,7 +281,7 @@ object Manga {
}
source.client.newCall(
GET(thumbnailUrl, source.headers),
GET(thumbnailUrl, source.headers, cache = CacheControl.FORCE_NETWORK),
).await()
}
@@ -306,7 +307,7 @@ object Manga {
mangaEntry[MangaTable.thumbnail_url]
?: throw NullPointerException("No thumbnail found")
network.client.newCall(
GET(thumbnailUrl),
GET(thumbnailUrl, cache = CacheControl.FORCE_NETWORK),
).await()
}

View File

@@ -14,7 +14,7 @@ import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.SourceFactory
import mu.KotlinLogging
import okhttp3.Request
import okhttp3.CacheControl
import okio.buffer
import okio.sink
import okio.source
@@ -272,8 +272,10 @@ object Extension {
url: String,
savePath: String,
) {
val request = Request.Builder().url(url).build()
val response = network.client.newCall(request).await()
val response =
network.client.newCall(
GET(url, cache = CacheControl.FORCE_NETWORK),
).await()
val downloadedFile = File(savePath)
downloadedFile.sink().buffer().use { sink ->
@@ -350,7 +352,7 @@ object Extension {
return getImageResponse(cacheSaveDir, apkName) {
network.client.newCall(
GET(iconUrl),
GET(iconUrl, cache = CacheControl.FORCE_NETWORK),
).await()
}
}