Skip to content

Commit b5bba74

Browse files
author
Derek Smart
committed
set cookie if returned
Signed-off-by: Derek Smart <derek.smart@delphix.com>
1 parent ace82c7 commit b5bba74

File tree

1 file changed

+10
-2
lines changed
  • src/main/kotlin/com/delphix/yamlparser/sdk

1 file changed

+10
-2
lines changed

src/main/kotlin/com/delphix/yamlparser/sdk/Http.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,17 @@ class Http(
2828
return mapOf("JSESSIONID" to JSESSIONID)
2929
}
3030

31-
fun setSession() {
32-
val r = post("$engineAddress$sessionResource", json = requestSessions())
31+
fun checkCookie(r: Response) {
32+
if (r.cookies.isNotEmpty()) {
3333
val cookie: String? = r.cookies["JSESSIONID"]
3434
val cookieArray: List<String>? = cookie?.split(";")
3535
JSESSIONID = cookieArray!!.get(0)
36+
}
37+
}
38+
39+
fun setSession() {
40+
val r = post("$engineAddress$sessionResource", json = requestSessions())
41+
checkCookie(r)
3642
}
3743

3844
fun validateResponse(response: JSONObject) {
@@ -50,6 +56,7 @@ class Http(
5056
json = content,
5157
cookies = getCookie()
5258
)
59+
checkCookie(response)
5360
validateResponse(response.jsonObject)
5461
return response.jsonObject
5562
}
@@ -59,6 +66,7 @@ class Http(
5966
"$engineAddress$url",
6067
cookies = getCookie()
6168
)
69+
checkCookie(response)
6270
validateResponse(response.jsonObject)
6371
return response.jsonObject
6472
}

0 commit comments

Comments
 (0)