Hello,
I have a little problem with "httpjob", when I send a POST to a website to login, it replies with a set-cookie and 302 redirect.
The problem is that I need to estract the cookie from the redirect page, because the final page doesn't have any cookie inside the response headers.
here my code
here the code to get response
How I can extract "set-cookie" from the page with 302 redirect? Thanks.
I have a little problem with "httpjob", when I send a POST to a website to login, it replies with a set-cookie and 302 redirect.
The problem is that I need to estract the cookie from the redirect page, because the final page doesn't have any cookie inside the response headers.
here my code
B4X:
Sub SubitoLogin_Click
action = "LOGIN"
Dim http As HttpJob
http.Initialize("request",Me)
http.PostString("https://thewebsite/login","username=123456&password=ABCDEF")
End Sub
here the code to get response
B4X:
private Sub jobDone (job1 As HttpJob)
If job1.Success = True Then
Risultato.Text = job1.GetString
Dim Result As String
Dim i As Int
If action = "LOGIN" Then
Dim resp As OkHttpResponse = job1.Response
Dim headers As Map = resp.GetHeaders
For Each key As String In headers.Keys
If key = "set-cookie" Then
Log(headers.Get(key))
End If
Next
End If
End If
End Sub
How I can extract "set-cookie" from the page with 302 redirect? Thanks.