ptsiogas
09/01/2021, 10:01 AMheader("Cookie", cookie)
but Ktor seems to ignore it.Aleksei Tirman [JB]
09/01/2021, 10:04 AMcookie
function to send Cookies. You can find an example in the documentation.hfhbd
09/01/2021, 10:04 AMcookie()
functionptsiogas
09/01/2021, 10:04 AMAleksei Tirman [JB]
09/01/2021, 10:05 AMptsiogas
09/01/2021, 10:15 AMclient.get("myEndpoint") {
cookie(name = "JSESSIONID", value = "uLOgaxWu7uF4tic5sBrXkBzvxB-rDWScF-fTDvB6Mj4F243gvhdo!-128011973")
}
I am doing something wrong?Aleksei Tirman [JB]
09/01/2021, 10:22 AMval client = HttpClient(CIO)
val r = client.get<String>("<https://httpbin.org/get>") {
cookie(name = "JSESSIONID", value = "uLOgaxWu7uF4tic5sBrXkBzvxB-rDWScF-fTDvB6Mj4F243gvhdo!-128011973")
}
println(r)
How do you check the result?ptsiogas
09/01/2021, 10:30 AMptsiogas
09/01/2021, 10:32 AMAleksei Tirman [JB]
09/01/2021, 10:44 AMAndroid
engine. Could you please check the actual presence of a Cookie
header in the Wireshark?ptsiogas
09/01/2021, 11:05 AMptsiogas
09/01/2021, 11:09 AMptsiogas
09/01/2021, 11:10 AMAleksei Tirman [JB]
09/01/2021, 11:25 AMGET / HTTP/1.1
Cookie: JSESSIONID=uLOgaxWu7uF4tic5sBrXkBzvxB%2DrDWScF%2DfTDvB6Mj4F243gvhdo%21%2D128011973
Accept-Charset: UTF-8
Accept: */*
User-Agent: Ktor client
Content-Length: 0
Host: localhost:7070
Connection: Keep-Alive
Accept-Encoding: gzip
HTTP/1.1 404 Not Found
Content-Length: 0
Connection: keep-alive
Aleksei Tirman [JB]
09/01/2021, 11:26 AMandroid:usesCleartextTraffic="true"
to make an insecure connection.ptsiogas
09/01/2021, 11:33 AMdefaultRequest {
cookie(
"JSESSIONID",
"uLOgaxWu7uF4tic5sBrXkBzvxB-rDWScF-fTDvB6Mj4F243gvhdo!-128011973"
)
}
hm it appears like it has urlEnconding
JSESSIONID=uLOgaxWu7uF4tic5sBrXkBzvxB%2DrDWScF%2DfTDvB6Mj4F243gvhdo%21%2D128011973
ptsiogas
09/01/2021, 1:11 PMinstall(HttpCookies) {
storage = AcceptAllCookiesStorage()
}
then all my “custom” cookies are being ignored.
If I remove that then everything plays well.
The thing is that I need to initially read the cookie from an API call and the AcceptAllCookiesStorage() declaration seems to me that is necessary.