Skip to content

Commit

Permalink
Support ppconsul::kw::enable_stop for libcurl <= 7.31.0 (e.g. RedHat 7)
Browse files Browse the repository at this point in the history
using deprecated CURLOPT_PROGRESSFUNCTION/CURLOPT_PROGRESSDATA inside
a #ifdef
  • Loading branch information
joconnor-openet authored and oliora committed Apr 15, 2020
1 parent aaec2f0 commit 309035c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/curl/http_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ namespace ppconsul { namespace curl {
const auto* client = static_cast<const HttpClient*>(clientPtr);
return client->isStopped();
}
// old-style progress callback for curl <= 7.31.0
int progressCallback_compat(void *clientPtr, double, double, double, double)
{
const auto* client = static_cast<const HttpClient*>(clientPtr);
return client->isStopped();
}
}

HttpClient::HttpClient(const std::string& endpoint, const TlsConfig& tlsConfig, bool enableStop)
Expand All @@ -169,12 +175,13 @@ namespace ppconsul { namespace curl {

if (m_enableStop)
{
#if (LIBCURL_VERSION_NUM >= 0x073200)
setopt(CURLOPT_NOPROGRESS, 0l);
#if (LIBCURL_VERSION_NUM >= 0x073200)
setopt(CURLOPT_XFERINFOFUNCTION, &progressCallback);
setopt(CURLOPT_XFERINFODATA, this);
#else
throw std::logic_error("Ppconsul is built without support for stopping the client (libcurl 7.32.0 or newer is required)");
setopt(CURLOPT_PROGRESSFUNCTION, &progressCallback_compat);
setopt(CURLOPT_PROGRESSDATA, this);
#endif
}
else
Expand Down

0 comments on commit 309035c

Please sign in to comment.