You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cpr::AcceptEncoding parameter does not work when downloading with cpr::Download causing it to fail to decode the downloaded file which is a gzip encoded.
Example/How to Reproduce
cpr::Url url{"http://anyurl/file.ext"}; // Make sure response should be with 'Content-Encoding: gzip' in it
cpr::Response r = cpr::Download(of, url);
std::cout << r.header["Content-Encoding"] << std::endl; // should be 'gzip'
After downloading you can see cpr::Download failed to decode the downloaded file.
Possible Fix
Following piece of code in Session::prepareCommonDownload solved the issue;
#if LIBCURL_VERSION_NUM >= 0x072100
if (acceptEncoding_.empty()) {
// Enable all supported built-in compressions
curl_easy_setopt(curl_->handle, CURLOPT_ACCEPT_ENCODING, "");
} else if (acceptEncoding_.disabled()) {
// Disable curl adding the 'Accept-Encoding' header
curl_easy_setopt(curl_->handle, CURLOPT_ACCEPT_ENCODING, nullptr);
} else {
curl_easy_setopt(curl_->handle, CURLOPT_ACCEPT_ENCODING, acceptEncoding_.getString().c_str());
}
#endif
This piece of code is same as in Session::prepareCommon
Where did you get it from?
GitHub (branch e.g. master)
Additional Context/Your Environment
OS: Linux
Version: 1.10.5
The text was updated successfully, but these errors were encountered:
Description
cpr::AcceptEncoding
parameter does not work when downloading withcpr::Download
causing it to fail to decode the downloaded file which is a gzip encoded.Example/How to Reproduce
After downloading you can see
cpr::Download
failed to decode the downloaded file.Possible Fix
Following piece of code in
Session::prepareCommonDownload
solved the issue;This piece of code is same as in
Session::prepareCommon
Where did you get it from?
GitHub (branch e.g. master)
Additional Context/Your Environment
The text was updated successfully, but these errors were encountered: