Android Question httpUtils en setheader cookie handling

bluedude

Well-Known Member
Licensed User
Longtime User
Hi,

I can set a cookie with httpGET.GetRequest.SetHeader ("cookie","sid=9849349839489349384934") but when the cookie is not valid httpUtils does not give me any feedback. It seems like the service is started but nothing happens.

When the cookie value is correct I get results.

I'm not even getting a error response.
 

bluedude

Well-Known Member
Licensed User
Longtime User
Hi timing does not seem to be the problem. When I change one thing in the cookie string httpUtils gets started but nothing gets reported back. Checked several logs but nothing seems to happen.
 
Upvote 0

bluedude

Well-Known Member
Licensed User
Longtime User
This is not a public URL. Tried everything but the problem seems to be that it gets stuck in hc_Responsesuccess. It gets in there but does not do Streamfinish.

What I do is set a cookie with a get (httputils Download), this works when the cookie is correct. When the cookie is not correct i'm not getting back anything. Waiting for a timeout would not be handy.

Is there an other way to check validity of a cookie almost realtime?

Basically this stuff is a session ID for user management.
 
Upvote 0

bluedude

Well-Known Member
Licensed User
Longtime User
Alright, found it. I needed to change something in hc_ResponseSuccess, in certain cases Response.GetAsynchronously does not get executed. Basically when a cookie is not correct there is empty content returned.
 
Upvote 0

bluedude

Well-Known Member
Licensed User
Longtime User
Something interesting is happening. When I always supply the correct cookie it works on and off. One call works and the second gives 204 error. Third is good again and fourth error 204.

I adapted hc_responseSuccess as follows:

Log ("Status code: " & Response.StatusCode & TaskId)
Select Case Response.StatusCode
Case 204
'no user found
CompleteJob(TaskId, False, "Unauthorized",401)
Case Else
End Select
Response.GetAsynchronously("response", File.OpenOutput(TempFolder, TaskId, False), _
True, TaskId)

204 is raised when there is no content. I pass this to CompleteJob with success false and creating error 401.

I'm 100% sure if error is 204 that GetAsynchronously it not called at all. However, when called it seems the cookie creates something to that the next call fails.
 
Upvote 0

bluedude

Well-Known Member
Licensed User
Longtime User
Hi,

I discovered setting the cookie in every call toggles my statuscode between 200 and 204. Basically it means you have to set your cookie only once otherwise it does not work. I'm now keeping track of if I already set my cookie before. If I wouldn't do that my connection will go wrong every second call.

Cheers.
 
Upvote 0
Top