Handling GZIP Compression using WININET API's
c, com, ole, winapi, wininet
Solution
Starting Vista, `INTERNET_OPTION_HTTP_DECODING` flag enables gzip decoding within WinInet:
INTERNET_OPTION_HTTP_DECODING:
Enables WinINet to perform decoding for the gzip and deflate encoding schemes. For more information, see Content Encoding.
When decoding fails, the application has two options: it can remove the Accept-Encoding header and resend the request, or it can set the INTERNET_OPTION_HTTP_DECODING option on the request to false and then resend the request. If the decoding option is set to false, the application must check the Content-Encoding header and perform any decoding at the application level.
In earlier version of Windows you would have to decompress yourself (which is also reasonably easy using e.g. http://zlib.net/)
Problem
My Server sends me a JSON data stream which is compressed using GZIP Compression. When I request this data on the normal IE Browser, I get the data and when I mention the application to open with, The Browser automatically decompresses that data stream and shows me my JSON data. My C Application is using COM/OLE to embed an IE Browser Instance and I am using WININET for GET/POST operations So here I get the data compressed. Since its IE Browser Functionality that decompresses the GZIP data automatically in the case of the default IE browser How can I get the data decrypted automatically via WININET in my C Application?