Android Tutorial HttpUtils2 - Web services are now even simpler

sule

Member
Licensed User
Longtime User
is there way in httputilis2 to set
("http.protocol.handle-redirects", False)
 

sule

Member
Licensed User
Longtime User
If you give more details maybe we can helpè you
B4X:
Sub Process_Globals
    Dim hc As HttpClient   
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        hc.Initialize("hc")
        hc.SetHttpParameter("http.protocol.handle-redirects", False)
    End If
    Dim req As HttpRequest
    req.InitializeGet("http://www.basic4android.com")
    hc.Execute(req, 1)
End Sub
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
    Log("success: " & Response.GetString("UTF8"))
End Sub
Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
    Log("Error")
    Log(StatusCode)
    If Floor(StatusCode / 100) = 3 Then '3xx status
        If response <> Null Then
            Log("Redirect to: " & response.GetHeaders.Get("Location"))
        End If   
    End If
End Sub
those not work with httputilis2
 

sule

Member
Licensed User
Longtime User
Do you see the code in HttpUtils2Service? It should be very simple to add this line.
this line canot be added
hc.Initialize("hc")
hc.SetHttpParameter("http.protocol.handle-redirects", False)
 

Cassie

Member
Licensed User
Longtime User
Hi,

can anyone have a sample how to call a secured http or "https" using HttpUtils2.

Thanks in advance
 

david13

Member
Licensed User
Hello, I got this error

src\anywheresoftware\b4a\samples\httputils2\httputils2service.java:154: error: cannot access ParseException

anywheresoftware.b4a.keywords.Common.Log(_response.GetString("UTF8"));

class file for org.apache.http.ParseException not found
 

david13

Member
Licensed User
Thanks for the answer,
I' using the core, Http,Reflection and stringutils libraries,, when I added HttpUtils2 I got this,
Error description: HttpUtils2Service is declared twice. You should either remove the library reference or the code module.Error parsing program.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…