content of pageReceived (xojo.Net.HTTPSocket)

Hello,
I’m testing the xojo.Net.HTTPSocket, and getting confused.
Receiving from a html page I use according to the docs:
dim buffer As text = xojo.Core.TextEncoding.UTF8.ConvertDataToText(content)
and I get the expected text-content.
But I dont understand how to deal when the content is binary data (pictures, pdf etc).

And by the way: how to detect if a content is binarydata or text?

Moreover, how to read headers.value of internetHeaders.
With the old socket I used:
dim s as text = DefineEncoding(headers.value(“Last-modified”),Encodings.utf8).ToText

Thanks

Wouldn’t you know before you download it?
If its an htm or html page, it’s text.
If your socket requests a picture, you will get binary data… save it to disc and use OpenAsPicture or similar to deal with it.

[quote=233648:@Carlo Rubini]Receiving from a html page I use according to the docs:
dim buffer As text = xojo.Core.TextEncoding.UTF8.ConvertDataToText(content)
and I get the expected text-content.
But I dont understand how to deal when the content is binary data (pictures, pdf etc).[/quote]

Don’t convert ‘content’ to a Text and just pass it around as a MemoryBlock.

Look at the “Content-Type” response header.

[quote=233648:@Carlo Rubini]Moreover, how to read headers.value of internetHeaders.
With the old socket I used:
dim s as text = DefineEncoding(headers.value(“Last-modified”),Encodings.utf8).ToText

[/quote]

You use the HTTPSocket’s ResponseHeader method.

Got it. Thank you.