B4i Library [class] HttpUtils2

Latest version is available here: https://www.b4x.com/android/forum/threads/b4x-okhttputils2-ihttputils2-httputils2-source-code.82632/

B4i implementation of HttpUtils2: http://www.b4x.com/android/forum/threads/httputils2-web-services-are-now-even-simpler.18992/#content

SS-2014-11-06_16.36.36.png


V2.10 is attached. See post #9 for more information.
Note that it requires B4i v2+. You can delete HttpJob.PostMultipart if you need to work with previous versions.
 

Attachments

  • HttpUtils2.zip
    4.9 KB · Views: 1,040
Last edited:

fbritop

Active Member
Licensed User
Longtime User
Erel,
What modification should be done to this class in order to accept invalid certificates from the server. I have done it in B4A but I cannot find what part to change in B4I

Thanks
FBP
 

melvin2345

Member
Licensed User
Longtime User
I'm trying to copy over a project from B4A, and one of the stumbling blocks I'm hitting is with httputils.

For example, in B4A I have
B4X:
HttpUtils.CallbackActivity = "Main"
HttpUtils.CallbackJobDoneSub = "DDVerDone"
HttpUtils.Download("JobV", DD_Version)

Sub DDVerDONE (Job As String)
    ShowLoading
  
    Dim DDVerString As InputStream
    If HttpUtils.IsSuccess(DD_Version) Then
        'Msgbox("Version Downloaded", "Version")
        DDVerString = HttpUtils.GetInputStream(DD_Version)
        DDData.ExecNonQuery("CREATE TABLE IF NOT EXISTS DDVersion (Version TEXT)")
        DDVParser.Parse(DDVerString, "VerParser")
    Else
        'Msgbox("Could not get version","VerUpdate")
        HideLoading
    End If
  
End Sub

B4i screams bloody murder on the HttpUtils calls. My question is, does the HttpUtils2 module for B4I allow for multiple custom "done" subs, or do i just need to check for the job in a single sub like this
B4X:
Sub JobDone (Job As HttpJob)
    Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
    If Job.Success = True Then
        Select Job.JobName
            Case "Job1", "Job2"
                'print the result to the logs
                Log(Job.GetString2("Windows-1252"))
            Case "Job3"
                'show the downloaded image
                ImageView1.Bitmap = Job.GetBitmap
        End Select
    Else
        Log("Error: " & Job.ErrorMessage)
        hd.ToastMessageShow("Error: " & Job.ErrorMessage, True)
    End If
    Job.Release
End Sub
 
Top