mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-05 21:55:24 +00:00
Add support for older versions of libcurl (e.g. those found on RHEL7) that do not have support for the newer CURLOPT_XFERINFODATA / CURLOPT_XFERINFOFUNCTION options.
This commit is contained in:
parent
dff519ee87
commit
c44343712d
@ -327,12 +327,20 @@ bool HttpDataStream::Open(const char *rawUri, OpenFlags flags) {
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_FAILONERROR, 1);
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_USERAGENT, "musikcube HttpDataStream");
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_NOPROGRESS, 0);
|
||||
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_WRITEHEADER, this);
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_WRITEDATA, this);
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_XFERINFODATA, this);
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_WRITEFUNCTION, &HttpDataStream::CurlWriteCallback);
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_HEADERFUNCTION, &HttpDataStream::CurlReadHeaderCallback);
|
||||
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_WRITEDATA, this);
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_WRITEFUNCTION, &HttpDataStream::CurlWriteCallback);
|
||||
|
||||
#if LIBCURL_VERSION_NUM < 0x072000
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_PROGRESSDATA, this);
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_PROGRESSFUNCTION, &HttpDataStream::LegacyCurlTransferCallback);
|
||||
#else
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_XFERINFODATA, this);
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_XFERINFOFUNCTION, &HttpDataStream::CurlTransferCallback);
|
||||
#endif
|
||||
|
||||
const int connectionTimeout = prefs->GetInt(kConnectionTimeoutSecondsKey.c_str(), kDefaultConnectionTimeoutSeconds);
|
||||
const int readTimeout = prefs->GetInt(kReadTimeoutSecondsKey.c_str(), kDefaultReadTimeoutSeconds);
|
||||
@ -578,4 +586,17 @@ int HttpDataStream::CurlTransferCallback(
|
||||
return -1; /* kill the stream */
|
||||
}
|
||||
return 0; /* ok! */
|
||||
}
|
||||
}
|
||||
|
||||
#if LIBCURL_VERSION_NUM < 0x072000
|
||||
int HttpDataStream::LegacyCurlTransferCallback(
|
||||
void *ptr, double downTotal, double downNow, double upTotal, double upNow)
|
||||
{
|
||||
return CurlTransferCallback(
|
||||
ptr,
|
||||
(curl_off_t) downTotal,
|
||||
(curl_off_t) downNow,
|
||||
(curl_off_t) upTotal,
|
||||
(curl_off_t) upNow);
|
||||
}
|
||||
#endif
|
@ -91,6 +91,10 @@ class HttpDataStream : public IDataStream {
|
||||
static size_t CurlReadHeaderCallback(char *buffer, size_t size, size_t nitems, void *userdata);
|
||||
static int CurlTransferCallback(void *ptr, curl_off_t downTotal, curl_off_t downNow, curl_off_t upTotal, curl_off_t upNow);
|
||||
|
||||
#if LIBCURL_VERSION_NUM < 0x072000
|
||||
static int LegacyCurlTransferCallback(void *ptr, double downTotal, double downNow, double upTotal, double upNow);
|
||||
#endif
|
||||
|
||||
std::string originalUri, httpUri, type;
|
||||
size_t length;
|
||||
std::string filename;
|
||||
|
Loading…
Reference in New Issue
Block a user