Hi all,
I try to implement HttpServer embed on android device (smartphone or tablet) base on this guidance
In the android part i need to do some rest to another server over internet
this is part of my HandleRequest event code:
When i try to call in the browser with:
The problem is when i run this address, the JobDone status was Success but no result shown (blank) in the browser side
Which expected result is: rraswisak, Google.com is ready
What i'm missing ?
Thank you
I try to implement HttpServer embed on android device (smartphone or tablet) base on this guidance
In the android part i need to do some rest to another server over internet
this is part of my HandleRequest event code:
B4X:
Sub Server_HandleRequest (Request As ServletRequest, Response As ServletResponse)
Try
Dim p As String = Request.GetParameter("name")
Log("Client: " & Request.RemoteAddress)
Select True
Case Request.RequestURI = "/"
Response.SendString($"Welcome ${p}"$)
Case Request.RequestURI = "/hi"
Response.SendString($"Greeting ${p}, how are you today ?"$)
Case Request.RequestURI = "/rest"
Dim j As HttpJob
Dim res As String
j.Initialize("", Me)
j.Download("https://www.google.com")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
res = $"${p}, Google.com is ready"$
Else
res = "Error access URL"
End If
j.Release
Response.SendString(res)
Case Else
Response.SendString("Invalid command!")
End Select
Catch
Response.Status=500
Log("Error serving request" & LastException)
Response.SendString("Invalid command !")
End Try
End Sub
When i try to call in the browser with:
The problem is when i run this address, the JobDone status was Success but no result shown (blank) in the browser side
Which expected result is: rraswisak, Google.com is ready
What i'm missing ?
Thank you