reading http data

nikdo

New Member
I use a POST method for sending some data to a server and the server replies me back within few seconds. The reply is usually text message "we received your data", however in some cases (depending what I send) it sends back a pictogram - see the attachments. I want to show the pictogram on the screen, then write it with a keyboard into a textbox and send it back again to the server. I suppose I have to read the reply in bytes, not as a text and then decode it to show the pictogram. Can the reading be done with a response object? Is the any example how to read http data in bytes?
If the server replies me with the pictogram I cannot see any received message. The response.ContentLength returns value -1
B4X:
    request.New1("http://......../main.php")
    request.Method = "POST"
    Request.ContentType = "application/x-www-form-urlencoded"
    stream.New1(Request.GetStream,True) 
    name = "src=" & textbox5.text & "&dst=" & textbox2.Text & "&msg=" & textbox3.Text & _
   "&usr=" & textbox7.Text & "&psw=" & textbox8.Text
    stream.WriteBytes(stream.StringToBytes(name))
    response.New1
    response.Value = request.GetResponse
    textbox4.text = response.GetString 
    response.Close
 

nikdo

New Member
1) Finally, I used the following:
B4X:
response.New1
response.Value = request.GetResponse
bin.New1(response.GetStream, True) 'BinaryFile object named bin
bit.New1  'Bitwise object named bit
Dim buffer(512) As byte
count = bin.ReadBytes(buffer(),512)

2) and for the pictogram:
B4X:
bitmap.New2(image1.Width,image1.Height) 'ImageLib object named bitmap
image1.Image = bitmap.Value
drawer.New2(bitmap.Value,B4PObject(5)) 'ImageLib object named drawer
pen1.New1 (cRed) 'ImageLib object named pen1
...
drawer.DrawLine(pen1.Value, (x*8)+n, y, (x*8)+n+1, y)
drawer.Refresh(0, 0, width, height)

Interresting thing is that on a PC the pictogram is shown properly, i.e. red numbers on white background but on the PDA it is red numbers on black background. (L)
 
Top