Strange HTTPSOCKET issue

I have a very strange issue with HTTPSOCKET:

Try the following:

dim http as new HTTPSocket http.Yield=true msgbox http.Get("", 15)

You will notice the msgbox will display garbage.

Now try : in any browser and you will notice it is readable JSON text. is not Json, but a HTML page, where the contains a

 element containing a string which can be read as JSON by human beings.

JSON or HTML … the issue remains. I get garbage when using the HTTPSOCKET.

No, you’re right. Should have checked the InternetHeaders. They come through correctly (content type: JSON). But the encoding is missing (something like charset: utf-8). Can you add the encoding to the server’s response header?

The string you get in your example is gzipped!

Are you sure? Why does a browser display it correctly (readable)?

Did a quick test … its not a gzip (or any other compressed file)

Oeps … sorry … it is indeed a zipped code. Strange.

What could be the fastest methode to make it readable? (without writing it first as a zip file, unzip it, and read the file again)

The headers says so:

HTTP/1.1 200 OK Reproxy-Status: yes Access-Control-Allow-Origin: * Content-Type: application/json Content-Encoding: gzip Server: lighttpd Content-Length: 1055 Date: Sat, 15 Feb 2014 16:37:01 GMT X-Varnish: 2046486739 2027595096 Age: 65473 Via: 1.1 varnish Connection: close

Indeed. See my previous answer.

Strange it is loaded as a gzip file while in a browser it displays correctly (plain text).

Now I need a way to unzip it into memory without writing it first to a file.

As I wrote in my very first answer, it is shown as a HTML page by the browser (Safari in my case). Same as with XML and other data formats. They are interpreted by the browser and shown within a HTML page created on the fly.

I don’t know how to gunzip in Xojo. I would probably try to call gunzip in a Shell.

Ok, works when I use GZipFileMBS