WinHTTP Decompression function?

2019-08-05 10:05发布

问题:

Presently I am using winhttp api in c++ to get data from a server. The server can support various compression formats. So presently I want to use winhttp to get the compressed format (eg gzip) and decompress it. Is it possible to decompress the data using winhttp?

回答1:

Surely it's possible.

From here:

To set the decoding option, the application calls InternetSetOption with the handle returned from InternetOpen, InternetConnect, or HttpOpenRequest. The INTERNET_OPTION_HTTP_DECODING option is specified in the dwOption parameter, and the lpBuffer parameter points to a boolean variable set to true. To disable decoding, the application calls InternetSetOption with the INTERNET_OPTION_HTTP_DECODING option and the boolean variable set to false.

So http compression is transprent for user code, you just need one call to InternetSetOption and your traffic will be compressed.



标签: http