Update HttpSession.kt

This commit is contained in:
Arjix 2021-09-02 16:06:46 +03:00 committed by GitHub
parent 019f9b4ba7
commit c283f9347b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,12 +19,12 @@ class HttpSession {
companion object {
const val DEFAULT_TIMEOUT = 30.0
fun mergeCookies(cookie1: Map<String, String>, cookie2: Map<String, String>?): Map<String, String> {
val a = cookie1.toMutableMap()
fun mergeCookies(cookie1: CookieJar, cookie2: Map<String, String>?): Map<String, String> {
val a = cookie1
if (!cookie2.isNullOrEmpty()) {
a.putAll(cookie2.toMap())
a.putAll(cookie2)
}
return a.toMap()
return a
}
}
@ -43,8 +43,8 @@ class HttpSession {
val res = khttp.get(
url, headers, params,
data, json, auth,
mergeCookies(sessionCookies, cookies),
timeout, allowRedirects,
mergeCookies(sessionCookies, cookies), timeout,
allowRedirects,
stream, files
)
sessionCookies.putAll(res.cookies)
@ -65,8 +65,8 @@ class HttpSession {
val res = khttp.post(
url, headers, params,
data, json, auth,
mergeCookies(sessionCookies, cookies),
timeout, allowRedirects,
mergeCookies(sessionCookies, cookies), timeout,
allowRedirects,
stream, files
)
sessionCookies.putAll(res.cookies)