ASCIIZ whith GET?

timo

Active Member
Licensed User
Longtime User
I'm very new whith http & PHP coding. I just want to understand why this simple example (get method) receives a sort of ASCIIZ response (0/nul ending added).Thanks

B4X:
<?php
$hst  = $_GET['hst'];
echo($hst);
?>
B4X:
Sub Process_Globals
Dim httpC As HttpClient
End Sub
Sub Globals
Dim hst As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
httpC.Initialize("httpC")
End If
check
End Sub
Sub check
Dim req As HttpRequest
req.InitializeGet("http://www.name.com/test.php?hst=12.123.123.12")
httpC.Execute(req,1)
End Sub
Sub httpC_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim result As String
result = Response.GetString("UTF8")
Log(result,"")
End Sub
Sub httpC_ResponseError (Response As HttpResponse, why As String, StatusCode As Int, TaskId As Int)
Msgbox("Connection error "&why,"Error ("&StatusCode&")")
End Sub
 

timo

Active Member
Licensed User
Longtime User
On the PHP side the variables are correctly received. The response is correct for numbers, but a zero (0) is added to strings after the last carachter (a sort of AsciiZ response). I think it could maybe depend on the PHP.ini configuration (I didn't look at at it yet). It's not too important once I know that strings arrives that way (just cut the zero before using them).
Anyway, as you confirmed me not to be a B4a coding problem, I will try to solve on the server side. Thank you Erel.
 
Upvote 0
Top