feat(Http): preserve cookies in-memory
Keep Cloudflare cookies in memory to reduce potential latency.
This commit is contained in:
parent
c840aac67e
commit
7384b562d5
1 changed files with 5 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ import io.ktor.client.engine.okhttp.OkHttp
|
|||
import io.ktor.client.plugins.cache.HttpCache
|
||||
import io.ktor.client.plugins.cache.storage.FileStorage
|
||||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
||||
import io.ktor.client.plugins.cookies.HttpCookies
|
||||
import io.ktor.client.plugins.defaultRequest
|
||||
import io.ktor.client.request.HttpRequestBuilder
|
||||
import io.ktor.client.request.header
|
||||
|
|
@ -66,6 +67,10 @@ fun Scope.provideHttpClient() = HttpClient(OkHttp) {
|
|||
publicStorage(FileStorage(dir))
|
||||
}
|
||||
|
||||
install(HttpCookies) {
|
||||
// Default storage is in-memory
|
||||
}
|
||||
|
||||
// Custom plugin to allow overriding response cache headers, and force caching
|
||||
install("OverrideCacheControl") {
|
||||
receivePipeline.intercept(HttpReceivePipeline.Before) { response ->
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue