I added curl_easy_setopt(client, CURLOPT_ENCODING, "gzip");
to my code.
I expected curl to cause the server to send compressed data AND to decompress it.
Actually i see in HTTP header that the data is compressed (Vary: Accept-Encoding Content-Encoding: gzip), but curl doesn't decompress it for me.
Is there an additional command I should use for this?
Note that this option has been renamed to
CURLOPT_ACCEPT_ENCODING
.As stated by the documentation:
So it does decode (i.e decompress) the response. Three encoding are supported:
"identity"
(does nothing),"zlib"
and"gzip"
. Alternatively you can pass an empty string which creates anAccept-Encoding:
header containing all supported encodings.At last, httpbin is handy to test it out as it contains a dedicated endpoint that returns gzip content. Here's an example:
It sends:
And gets as response:
And a JSON response (thus decompressed) is written on stdout.
c++ CURL library does not compress/decompress your data. you must do it yourself.