libcpr / cpr

C++ Requests: Curl for People, a spiritual port of Python Requests.
https://docs.libcpr.org/
Other
6.59k stars 937 forks source link

Not working properly with libcurl v8.1.2 #919

Closed ZACKhdn closed 1 year ago

ZACKhdn commented 1 year ago

Description

If I use libcurl v8.1.2,the gzip cannot work. In session.cpp, I found the following content:

#if LIBCURL_VERSION_MAJOR >= 7
#if LIBCURL_VERSION_MINOR >= 21
    if (acceptEncoding_.empty()) {
        /* enable all supported built-in compressions */
        curl_easy_setopt(curl_->handle, CURLOPT_ACCEPT_ENCODING, "");
    } else {
        curl_easy_setopt(curl_->handle, CURLOPT_ACCEPT_ENCODING, acceptEncoding_.getString().c_str());
    }
#endif
#endif

Maybe this part needs to be revised

COM8 commented 1 year ago

@ZACKhdn Thanks for reporting. Please stick to the issue template for the next time. Else I will just close your issues.

I can confirm this issue and will look into it.

COM8 commented 1 year ago

I created a fix for it here: https://github.com/libcpr/cpr/pull/922

Could you please validate that it fixes your issues?

ZACKhdn commented 1 year ago

I created a fix for it here: #922

Could you please validate that it fixes your issues?

Yes, it works properly. I have already modified and used it like this. I found a macro "__LIBCURL_VERSION_GTE" in ssl_options.h, perhaps you can consider using this macro.

COM8 commented 1 year ago

Good point! Simplified it even further by using the hex version number. __LIBCURL_VERSION_GTE and __LIBCURL_VERSION_LTE will be replaced at one point with this way of comparing versions as well.

ZACKhdn commented 1 year ago

Good point! Simplified it even further by using the hex version number. __LIBCURL_VERSION_GTE and __LIBCURL_VERSION_LTE will be replaced at one point with this way of comparing versions as well.

OK,thank you for your work.