Skip to content

Instantly share code, notes, and snippets.

@yiheng0

yiheng0/CookieJarKt.kt Secret

Created Jan 22, 2021
Embed
What would you like to do?
package moe.yiheng
import okhttp3.Cookie
import okhttp3.CookieJar
import okhttp3.HttpUrl
class CookieJarKt : CookieJar {
var cookies: MutableList<Cookie>? = null
override fun saveFromResponse(url: HttpUrl?, cookies: MutableList<Cookie>?) {
if (cookies == null) return
if (this.cookies == null) this.cookies = cookies
if (url.toString() == "http://form.hhu.edu.cn/pdc/form/list") {
this.cookies = cookies
}
}
override fun loadForRequest(url: HttpUrl?): MutableList<Cookie>? {
return cookies ?: mutableListOf()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment