Android Question Unable to read httpjob response headers

PierPaduan

Active Member
Licensed User
Longtime User
Hi.
My Android App has OkHttp and OkHttpUtils2 libraries. Now I use B4A v.8.80.
In this app, about two years ago I have implemented a HTTP communication with a remote server. May be that at that time I was using HttpUtils library.
The communication was working very good and was working in the iOS version of the same app too (with iHttp library).
This communication has been not used till today, but now I need to use it.
The JobDone event is the following (it'is the same in Android and in iOS):
B4X:
Sub JobDone(j As HttpJob)
    If j.Success Then
        If    j.JobName = "signup" Then    'TEST 15/06/2017
            Log("j.GetString = " & j.GetString)
            Log("j.Tag = " & j.Tag)
            If j.GetString.Contains("status") And j.GetString.Contains("ok") Then
                Dim Headers As Map = j.tag           
                If Headers.Size > 0 Then
                    If Headers.Get(TokenHeaderName) <> "" Then   
                        LastToken = Headers.Get(TokenHeaderName)
                        '*************************************
The problem is that the Android app crashes when reach this line:
B4X:
 Dim Headers As Map = j.tag

But the iOS app still works fine like two years ago
.

If in the Android app I put a breakpoint before that line and I check J.Tag it appears as empty.

The Android Log is this:
The iOS Log is this:
Please someone can help me to fix this problem?
Thanks a Lot to everybody.
 

DonManfred

Expert
Licensed User
Longtime User
Please someone can help me to fix this problem?
Asuming you are using the newest b4a and okhttputils libraries

B4X:
Sub JobDone (Job As HttpJob)
    Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
    If Job.Success = True Then
        Dim response As OkHttpResponse = Job.Response
        Dim respHeaders As Map = response.GetHeaders
        log(respHeaders)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…