WinHTTP Decompression function?

2019-08-05 09:36发布

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?

标签: http
1条回答
虎瘦雄心在
2楼-- · 2019-08-05 10:12

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.

查看更多
登录 后发表回答