Cleanup okhttp usage

This commit is contained in:
GG Bond authored and Vladimir Dostoyevskiy committed 2023-12-04 20:30:24 +08:00
1 parent d1c7434993
commit fc63c41ab0
2 files changed
-6

No files matched your search

@@ -9,7 +9,6 @@ import io.ktor.http.Cookie
import io.ktor.http.Url
import io.ktor.http.parseClientCookiesHeader
import io.ktor.http.renderSetCookieHeader
import okhttp3.HttpUrl
object EhCookieStore : CookiesStorage {
private val manager = CookieManager.getInstance()
@@ -42,10 +41,6 @@ object EhCookieStore : CookiesStorage {
}
}
fun deleteCookie(url: HttpUrl, name: String) {
manager.setCookie(url.toString(), "$name=;Max-Age=0")
}
fun addCookie(k: String, v: String, domain: String) {
val cookie = Cookie(name = k, value = v, domain = domain, maxAge = Int.MAX_VALUE)
val url = if (EhUrl.DOMAIN_E == cookie.domain) EhUrl.HOST_E else EhUrl.HOST_EX
@@ -3,4 +3,3 @@ package com.hippo.ehviewer.ktbuilder
import okhttp3.OkHttpClient
inline fun httpClient(builder: OkHttpClient.Builder.() -> Unit): OkHttpClient = OkHttpClient.Builder().apply(builder).build()
inline fun httpClient(client: OkHttpClient, builder: OkHttpClient.Builder.() -> Unit): OkHttpClient = client.newBuilder().apply(builder).build()