May 22, 2024, 04:58:08 AM


Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........

Using sockets, HTTP and gzip

Started by sapero, February 28, 2007, 03:19:50 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


February 28, 2007, 03:19:50 PM Last Edit: March 01, 2007, 07:53:53 AM by sapero
This example shows how to download a file from internet using low level socket functions.
It shows how to parse received HTTP headers placing them in string dictionary, and how to speed up downloading by requesting server side file compression.

To request compression we need to add in request header:"Accept-Encoding: gzip" {plus optional ", deflate"} //without quotations.
If the server supports compression and can compress the requested file, will add this line in response headers:Content-Encoding: gzip
The format of gzipped file can be raw (just rename the file to .gz) or chunked, we need to check existence ofTransfer-Encoding: chunkedand eventually merge all chunks and truncate the file.

To un-gzip - I've used zlib1.dll available on windows xp/vista, or free to download and use from
As well this example uses structured exceptions handling to break on any error.

It downloads from three servers:
1. - chunked gzip
2. - gzip
3. - no compression


The attachment has been modified - the Unchunk function call has moved right after downloading, before decompressing. Any file can be chunked, uncompressed html too!.
The format of "deflate" compression is same as gzip (function inflate failed) - updated.
Added emergence version.

Ionic Wind Support Team

Thanks Sapero for including both an Aurora and Emergence version.

Good stuff!
Ionic Wind Support Team